Forum Moderators: coopster

Message Too Old, No Replies

How to read URL Segments?

         

shafaki

8:40 pm on Apr 7, 2007 (gmt 0)

10+ Year Member



Passing parameters to a PHP script via the URL is normally done by using the question mark:
http://www.example.com/index.php?c=foo&a=stuff

However, I've seen some sites usa a different URL structure:
http://www.example.com/index.php/foo/stuff

How does Apache behave in this case? Does it call the index.php file, and does it then pass the "/foo/stuff" string to it?

Does Apache need any special configuration to do this, or it does this by default? If so, how then can I catch such string "/foo/stuff" in my PHP script?

jdMorgan

8:46 pm on Apr 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See Apache 2.x core AcceptPathInfo [httpd.apache.org] directive.

Jim

shafaki

12:58 pm on Apr 8, 2007 (gmt 0)

10+ Year Member



Thanks for this useful info.

I've also seen segment URLs (/index.php/foo/stuff) work on systems running Apache 1.3

jdMorgan

1:24 pm on Apr 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Apache 1.3 doesn't support AcceptPath info, so you'd have to use mod_rewrite:

A guide to search-engine-friendly links with mod_rewrite [webmasterworld.com] from our WebmasterWorld library.

Jim