url splitting

Thread Solved

Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

url splitting

 
0
  #1
Nov 4th, 2007
i forgot how to split urls

  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??
Do a favour, leave me alone
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 30
Reputation: chmazur is an unknown quantity at this point 
Solved Threads: 3
chmazur's Avatar
chmazur chmazur is offline Offline
Light Poster

Re: url splitting

 
0
  #2
Nov 5th, 2007
<?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.-
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: url splitting

 
0
  #3
Nov 5th, 2007
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
Do a favour, leave me alone
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 30
Reputation: chmazur is an unknown quantity at this point 
Solved Threads: 3
chmazur's Avatar
chmazur chmazur is offline Offline
Light Poster

Re: url splitting

 
0
  #4
Nov 5th, 2007
Did you test my script?
You can obtain all the blocks that you want. With or wihtout some block.

ch.-
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: url splitting

 
0
  #5
Nov 5th, 2007
yes i did.. but it s not the thing i want.
i will work on it

  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.
Do a favour, leave me alone
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: url splitting

 
0
  #6
Nov 5th, 2007
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.
Do a favour, leave me alone
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: url splitting

 
0
  #7
Nov 5th, 2007
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]
Do a favour, leave me alone
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC