User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,580 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,610 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 752 | Replies: 6 | Solved
Reply
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Question url splitting

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Location: Buenos Aires
Posts: 30
Reputation: chmazur is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
chmazur's Avatar
chmazur chmazur is offline Offline
Light Poster

Re: url splitting

  #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  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: url splitting

  #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  
Join Date: Sep 2007
Location: Buenos Aires
Posts: 30
Reputation: chmazur is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
chmazur's Avatar
chmazur chmazur is offline Offline
Light Poster

Re: url splitting

  #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  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: url splitting

  #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. ?>
  25.  
  26.  
Last edited by fatihpiristine : Nov 5th, 2007 at 10:31 am.
Do a favour, leave me alone
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: url splitting

  #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  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Solution Re: url splitting

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 6:22 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC