all external URLs look like 'module/action?key1=param1'. No customization possible--but it's fast. The difference is that the first uses PHP's GET, and the second uses PATH_INFO.

I've seen PATH_INFO several times, but still don't know what exactly it is. What does it do?

share|improve this question
up vote 34 down vote accepted

Actually, PATH_INFO is related to the Apache Web Server serving PHP pages and not PHP per se.

PATH_INFO is an environment variable set by Apache when the AcceptPathInfo directive is turned on. It will contain trailing pathname information that follows an actual filename or non-existent file in an existing directory, whether the request is accepted or rejected. Environment variables are then passed on to the Apache/CGI module in charge of rendering the page.

The variable is accessible in PHP using $_SERVER['PATH_INFO'].

For example, assume the location /test/ points to a directory that contains only the single file here.html. Then requests for /test/here.html/more and /test/nothere.html/more both collect /more as PATH_INFO.

Apache Core Documentation: AcceptPathInfo Directive

share|improve this answer
8  
After reading your answer, one could infer it's a bad practice to rely on PATH_INFO and it isn't. PATH_INFO is part of of the definition for CGI (as SimonSinCity pointed). It is supported by most web server, not just Apache. – Francisco R Aug 9 '14 at 9:29

As the variable PATH_INFO is part of the definition for CGI you should also take a look in there ;)

https://tools.ietf.org/html/rfc3875#section-4.1.5

share|improve this answer
5  
More accurate tools.ietf.org/html/rfc3875#section-4.1.5 – gavenkoa May 12 '14 at 15:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.