stripping variable from a URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
obewan
Forum Newbie
Posts: 5
Joined: Wed Oct 15, 2003 8:25 pm

stripping variable from a URL

Post by obewan »

http://www.xyz.com/index.php/toast

Can I easily strip the "toast" variable from this URL without using a "?". If not, is there a way to setup the server to use this format:

http://www.xyz.com/?toast

Right now, the above format returns an error since I'm not putting in the "index.php".

Thanks.
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

Post by Kriek »

The easiest way is with mod_rewrite in an .htaccess file:

Code: Select all

<IfModule mod_rewrite.c> 
  RewriteEngine on 
  RewriteRule ^index/(.*)/$ index.php?id=$1
</IfModule>
Then your link would be: http://example.com/index/toast/
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

i was useing

http://www.mysite.com/folder/?bla=1

for a while, it worked fine...untill i tried it out with opera 8O, so now i use
http://www.mysite.com/folder/index.php?bla=1...

i dont really see any problem with adding "index.php"part to it :?.
obewan
Forum Newbie
Posts: 5
Joined: Wed Oct 15, 2003 8:25 pm

Post by obewan »

Thanks.
Post Reply