Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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
Php 404已返回,但重写规则已匹配_Php_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Php 404已返回,但重写规则已匹配

Php 404已返回,但重写规则已匹配,php,apache,.htaccess,mod-rewrite,url-rewriting,Php,Apache,.htaccess,Mod Rewrite,Url Rewriting,我有一个将所有请求发送到index.php的重写规则: 它可以工作,除非请求路径以index/开头,在这种情况下,结果是找不到404 如果我将index.php的文件名更改为index2.php,并且重写规则与之匹配,它将再次开始工作,因此当文件名的第一段等于路径的第一段时,显然存在冲突 请求/index/hello时,mod_重写日志包含以下内容,但失败: add path info postfix: /path/to/index.php -> /path/to/index.php/he

我有一个将所有请求发送到index.php的重写规则:

它可以工作,除非请求路径以index/开头,在这种情况下,结果是找不到404

如果我将index.php的文件名更改为index2.php,并且重写规则与之匹配,它将再次开始工作,因此当文件名的第一段等于路径的第一段时,显然存在冲突

请求/index/hello时,mod_重写日志包含以下内容,但失败:

add path info postfix: /path/to/index.php -> /path/to/index.php/hello
strip per-dir prefix: /path/to/index.php/hello -> index.php/hello
applying pattern '^.*$' to uri 'index.php/hello'
rewrite 'index.php/hello' -> 'index.php'
add per-dir prefix: index.php -> /path/to/index.php
initial URL equal rewritten URL: /path/to/index.php [IGNORING REWRITE]
为了可读性,删除或修改了一些日志信息

我的服务器是Apache/2.2.22


如何修复此问题?

根据@wrikken在Serverfault中的建议,我添加了以下内容:

Options -Multiviews

请附上完整的访问权限file@RizwanSultan,只有一条规则,加上顶部的RewriteEngine。尝试定义RewriteBase/如果你的网站托管在根上,它唯一的作用是RewriteBase/测试/如果你的网站托管在测试上folder@RizwanSultan,我在第2行添加了RewriteBase/但它没有改变任何东西。该网站位于根目录下。无法复制。在my.htaccess中只有这个规则,即使/index/也会转到/index.php,并且在任何情况下都没有404。是否可以显示请求路径的重写日志,以索引/?开头,首先在此处回答:
Options -Multiviews