I am just curious, how is feature of apache is called that is directing requests like this
www.example.com/index.php/my/path/here
to a file index.php? At the first moment, you might think, that it would be correct if this request leads to 404 error page because there is no folder called index.php at the site root dir.
BTW, is there a possibility to turn off this Apache feature (if it is a feature) so that such requests really end up with 404?
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
asPATH_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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.