Welcome to WebmasterWorld Guest from 54.157.225.99

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

How to read URL Segments?

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

Junior Member

10+ Year Member

joined:Nov 17, 2004
posts:195
votes: 0


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?

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

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


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

Jim

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

Junior Member

10+ Year Member

joined:Nov 17, 2004
posts: 195
votes: 0


Thanks for this useful info.

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

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

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members