[英]Why www.example.com/index.php/my/path/here is processed by index.php?
I am just curious, how is feature of apache is called that is directing requests like this 我只是很好奇,如何调用apache的功能来指导这样的请求
www.example.com/index.php/my/path/here
to a file index.php? 到文件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.
在第一时刻,您可能会认为,如果此请求导致404错误页面将是正确的,因为站点根目录中没有名为index.php的文件夹 。
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? 顺便说一句,有没有可能关闭这个Apache功能(如果它是一个功能),这样的请求真的最终得到404?
This isn't a URL rewrite feature. 这不是URL重写功能。 Or at least it doesn't need to be.
或者至少它并不需要的人。 See AcceptPathInfo Directive :
请参阅AcceptPathInfo指令 :
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.尾随路径名信息可供
PATH_INFO
环境变量中的脚本使用。For example, assume the location /test/ points to a directory that contains only the single file
here.html
.例如,假设位置/ test /指向仅包含单个文件
here.html
。 Then requests for/test/here.html/more
and/test/nothere.html/more
both collect/more
asPATH_INFO
.然后请求
/test/here.html/more
和/test/nothere.html/more
都收集/more
作为PATH_INFO
。
It was originally a CGI environment variable . 它最初是一个CGI环境变量 。
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
.额外信息以
PATH_INFO
形式发送。 This information should be decoded by the server if it comes from a URL before it is passed to the CGI script.如果服务器在传递给CGI脚本之前来自URL,则应该对此信息进行解码。
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". 这是一种将信息传递给(在本例中)
index.php
脚本而不使用查询字符串的方法,一些搜索引擎会忽略该字符串,因此文章的名称为“搜索引擎友好URL”。
I can recommend the third method discussed in the article because it avoids strange looking URLS with index.php
in the middle. 我可以推荐文章中讨论的第三种方法,因为它避免了奇怪的URLS,中间有
index.php
。
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. 在那里你可以有一个像index.php这样的文件从服务器检查PATH_INFO并处理整个内容树。 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.
虽然我无法将其关闭,但您可以让index.php检查非空的$ _SERVER ['PATH_INFO']并通过header()函数响应404代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.