homepage Welcome to WebmasterWorld Guest from 54.211.7.174
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
How to read URL Segments?
shafaki




msg:3305163
 8:40 pm on Apr 7, 2007 (gmt 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?

 

jdMorgan




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

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

Jim

shafaki




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

Thanks for this useful info.

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

jdMorgan




msg:3305549
 1:24 pm on Apr 8, 2007 (gmt 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved