944,185 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1415
  • PHP RSS
Nov 4th, 2007
0

url splitting

Expand Post »
i forgot how to split urls

php Syntax (Toggle Plain Text)
  1. $url = "http://www.myhost.com/1,1,1,10.html";

i m trying to get 1,1,1,10.html n assign each value before commas to variables

any ideas??
Similar Threads
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Nov 5th, 2007
0

Re: url splitting

<?php
$urloriginal = "http://www.mazur.com.ar/galeria/index.php?id=25";
echo "URL original: " . $urloriginal . "<br><br>\n";
$urloriginal = eregi_replace("http://", "", $urloriginal);
echo "URL original sin http//: " . $urloriginal . "<br><br>\n";
$parametros = stristr($urloriginal, "/");
echo "The request part: " . $parametros . "<br><br>\n";
$dominio = substr($urloriginal, 0, strpos($urloriginal, "/"));
echo "El dominio es: $dominio";
?>

ch.-
Reputation Points: 10
Solved Threads: 3
Light Poster
chmazur is offline Offline
30 posts
since Sep 2007
Nov 5th, 2007
0

Re: url splitting

i dont think you get the point.

i meant i wanna destroy this block: 0,0,1,1.html and assign each value to variable
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Nov 5th, 2007
0

Re: url splitting

Did you test my script?
You can obtain all the blocks that you want. With or wihtout some block.

ch.-
Reputation Points: 10
Solved Threads: 3
Light Poster
chmazur is offline Offline
30 posts
since Sep 2007
Nov 5th, 2007
0

Re: url splitting

yes i did.. but it s not the thing i want.
i will work on it

php Syntax (Toggle Plain Text)
  1. <?
  2.  
  3. // i add this part
  4.  
  5. $_SERVER['FULL_URL'] = 'http';
  6. if($_SERVER['HTTPS']=='on'){$_SERVER['FULL_URL'] .= 's';}
  7. $_SERVER['FULL_URL'] .= '://';
  8. if($_SERVER['SERVER_PORT']!='80') $_SERVER['FULL_URL'] .= $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME'];
  9. else
  10. $_SERVER['FULL_URL'] .= $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
  11. if($_SERVER['QUERY_STRING']>' '){$_SERVER['FULL_URL'] .= '?'.$_SERVER['QUERY_STRING'];}
  12. $url = $_SERVER['FULL_URL'];
  13.  
  14.  
  15.  
  16. $urloriginal = $url;
  17. echo "URL original: " . $urloriginal . "<br><br>\n";
  18. $urloriginal = eregi_replace("http://", "", $urloriginal);
  19. echo "URL original sin http//: " . $urloriginal . "<br><br>\n";
  20. $parametros = stristr($urloriginal, "/");
  21. echo "The request part: " . $parametros . "<br><br>\n";
  22. $dominio = substr($urloriginal, 0, strpos($urloriginal, "/"));
  23. echo "El dominio es: $dominio";
  24. ?>
Last edited by fatihpiristine; Nov 5th, 2007 at 10:31 am.
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Nov 5th, 2007
0

Re: url splitting

tested and works ok..
another thing.. this is my url

http://www.blabla.com/en/category/25698

assignment:
language = en
category = category
id = 25698

sql does the query but when i redirect to this location i got 404 error.
how can i solve this?s
Last edited by fatihpiristine; Nov 5th, 2007 at 4:15 pm.
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Nov 5th, 2007
0

Re: url splitting

i figured out. with htaccess file

RewriteEngine On

RewriteRule ^\.htaccess$ - [F] #to avoid accessing .htaccess files
RewriteRule ^\.jpg$ - [F] #jpg
RewriteRule ^\.html$ - [F] # htmls
RewriteRule ^\.css$ - [F] # css


RewriteRule ^([0-9]+),([0-9]+)$ /index.php?Language=$1&Index=$2 [L]
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: MySQL vs. SQL Server
Next Thread in PHP Forum Timeline: What's going on here?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC