Page 1 of 1

URL Variables Using Slashes

Posted: Fri Oct 13, 2006 8:57 am
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!

Posted: Fri Oct 13, 2006 9:10 am
by neophyte
You'll want to take a look at apache mod_write.

Posted: Fri Oct 13, 2006 9:45 am
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

Posted: Fri Oct 13, 2006 10:02 am
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).