Why www.example.com/index.php/my/path/here is processed by index.php? Why www.example.com/index.php/my/path/here is processed by index.php? apache apache

Why www.example.com/index.php/my/path/here is processed by index.php?


This isn't a URL rewrite feature. Or at least it doesn't need to be. See AcceptPathInfo Directive:

This directive controls whether requests that contain trailing pathname information that follows an actual filename (or non-existent file in an existing directory) will be accepted or rejected. The trailing pathname information can be made available to scripts in the PATH_INFO environment variable.

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.

It was originally a CGI environment variable.

  • PATH_INFO

The extra path information, as given by the client. In other words, scripts can be accessed by their virtual pathname, followed by extra information at the end of this path. The extra information is sent as PATH_INFO. This information should be decoded by the server if it comes from a URL before it is passed to the CGI script.


Refer to this link for an explanation.

It is a method of passing information to the (in this case) index.php script without using a query string, which would be ignored by some search engines, hence the name of the article "Search Engine-Friendly URLs".

I can recommend the third method discussed in the article because it avoids strange looking URLS with index.php in the middle.


It's there that you can have a file like index.php check the PATH_INFO from the server and handle a whole tree of content. While there's no way I know of to turn it off, you can simply have index.php check for a non-empty $_SERVER['PATH_INFO'] and respond with a 404 code via the header() function.