Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How reliable are URIs like /index.php/seo_path

I noticed, that sometimes (especially where mod_rewrite is not available) this path scheme is used:

http://host/path/index.php/clean_url_here
--------------------------^

This seems to work, at least in Apache, where index.php is called, and one can query the /clean_url_here part via $_SERVER['PATH_INFO']. PHP even kind of advertises this feature. Also, e.g., the CodeIgniter framework uses this technique as default for their URLs.

The question: How reliable is the technique? Are there situations, where Apache doesn't call index.php but tries to resolve the path? What about lighttpd, nginx, IIS, AOLServer?

A ServerFault question? I think it's got more to do with using this feature inside PHP code. Therefore I ask here.

Addendum: As suggested by VolkerK, a reasonable extension to this question is: How can a programmer influence the existence of $_SERVER['PATH_INFO'] on various server types?

like image 855
Boldewyn Avatar asked Apr 14 '10 07:04

Boldewyn


2 Answers

I think this a question which is equally suited for stackoverflow and serverfault. E.g. I as a developer can only tell you that pathinfo is as trustworthy as any user-input (which means it can contain virtually anything) and your script may or may not receive it depending on the webserver version and configuration:

Apache: AcceptPathInfo
IIS: e.g. AllowPathInfoForScriptMappings and others
and so on and on...

But server admins possibly can tell you which settings you can expect "in the real world" and why those settings are preferred.
So the question becomes: How much influence do you (or the expected userbase) have on the server configuration.

like image 146
VolkerK Avatar answered Oct 28 '22 04:10

VolkerK


AcceptPathInfo needs to be enabled in order to have this working.

like image 25
Gumbo Avatar answered Oct 28 '22 05:10

Gumbo