简体   繁体   English

为什么www.example.com/index.php/my/path/here由index.php处理?

[英]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 as PATH_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.

相关问题 Ubuntu-如何直接将example.com/opencart/index.php定向到http://example.com/和www.example.com? - Ubuntu - How direct example.com/opencart/index.php to http://example.com/ and www.example.com? 当我在地址栏中按回车键时,Laravel 6 重定向到 https://www.example.com/index.php,地址为 www.example.com/profile? - Laravel 6 redirecting to https://www.example.com/index.php when I press enter in the address bar with an address of www.example.com/profile? 如何将网址从www.example.com/index.php?store=test重写为.htacess中的test.example.com或www.test.example.com - How to rewrite the url from www.example.com/index.php?store=test to test.example.com or www.test.example.com in .htacess codeigniter网址http://www.website.com/index.php/index.php/page - codeigniter url http://www.website.com/index.php/index.php/page 如果网址中没有index.php,example.com / index.php中的首页无法加载 - Home page is not loading without index.php in url, example.com/index.php 不需要来自 example.com/{lang}/index.php 的 index.php - Not needing index.php from example.com/{lang}/index.php PHP - 为什么“Index.php?action =”不被识别为“Index.php?” - PHP - Why is “Index.php?action=” not recognized as “Index.php?” “ example.com/index.php/page/about/”是好的做法吗? - Is “example.com/index.php/page/about/” good practice? htaccess-添加www并删除index.php - htaccess - add www & remove index.php Codeigniter htaccess删除index.php和www - Codeigniter htaccess to remove index.php and www
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM