URL Variables Using Slashes

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
FreakyT
Forum Newbie
Posts: 1
Joined: Fri Oct 13, 2006 8:48 am

URL Variables Using Slashes

Post by FreakyT »

I've been switching between sections on my website with URL variables. (for example, index.php?section=1) However, I noticed recently that Wikipedia has pages written like this: "index.php/Main_Page".

How does one go about using this sort of thing in php?

Thanks!
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

You'll want to take a look at apache mod_write.
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Post by MrPotatoes »

there are ways of doing it without mod_rewrite. i have it done but the index.php still shows up. no biggie.

and you parse thru it with an inedxed array. wicked easy. let me see if i can find the link to the tutorial somewhere on here
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Yep, you can do it without mod_rewrite. Use $_SERVER['PHP_SELF'] with the explode() function and you'll be fine.

P.S Don't forget to sanitize the data before working with it :wink:

Edit:
You can also use $_SERVER['PATH_INFO'], but I believe it will work only under Apache and even when you are running Apache, it might not be defined.
Also, the idea of using $_SERVER['PHP_SELF'] will only work under Apache I believe (but not sure).
Post Reply