Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么www.example.com/index.php/my/path/here由index.php处理?_Php_Apache_Friendly Url - Fatal编程技术网

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

为什么www.example.com/index.php/my/path/here由index.php处理?,php,apache,friendly-url,Php,Apache,Friendly Url,我只是好奇,apache的特性是如何调用的,它是如何引导这样的请求的 www.example.com/index.php/my/path/here 到index.php文件?首先,您可能会认为,如果此请求导致404错误页面,则是正确的,因为在站点根目录中没有名为index.php的文件夹 顺便说一句,是否有可能关闭此Apache功能(如果它是一项功能),以便此类请求真正以404结束?在那里,您可以使用类似index.php的文件从服务器检查路径信息并处理整个内容树。虽然据我所知,无法将其关闭,

我只是好奇,apache的特性是如何调用的,它是如何引导这样的请求的

www.example.com/index.php/my/path/here
到index.php文件?首先,您可能会认为,如果此请求导致404错误页面,则是正确的,因为在站点根目录中没有名为index.php的文件夹


顺便说一句,是否有可能关闭此Apache功能(如果它是一项功能),以便此类请求真正以404结束?

在那里,您可以使用类似index.php的文件从服务器检查路径信息并处理整个内容树。虽然据我所知,无法将其关闭,但您只需让index.php检查非空的$_服务器['PATH\u INFO'],然后通过header()函数以404代码响应即可。

这不是URL重写功能。或者至少不需要这样。见:

本指令控制 包含尾随的请求 路径名之后的路径名信息 实际文件名(或不存在的文件) 在现有目录中)将 接受或拒绝。尾随 可以创建路径名信息 中的脚本可用
PATH\u INFO
环境变量

例如,假设位置为 /test/指向一个 仅包含单个文件
here.html
。然后请求
/test/here.html/more
/test/nothere.html/more
两者都收集
/more
作为
路径信息

这本来是一个很好的例子

  • 路径信息
额外的路径信息,如给定的 由客户提供。换句话说,脚本 可通过其虚拟服务器访问 路径名,后跟额外的 此路径末尾的信息。 额外的信息发送为
路径信息
。这些信息应该 由服务器解码(如果有) 在将URL传递到 CGI脚本

有关说明,请参阅

它是一种将信息传递给(在本例中)index.php
脚本而不使用查询字符串的方法,某些搜索引擎会忽略该字符串,因此本文的名称为“搜索引擎友好URL”


我可以推荐本文中讨论的第三种方法,因为它避免了奇怪的URL,其中的代码<> index .php >中间。

谢谢,这是一篇非常有趣的文章。