![哪个指令可以让 apache/rewrite 重定向 products/ 到 products.php](https://linux22.com/image/530325/%E5%93%AA%E4%B8%AA%E6%8C%87%E4%BB%A4%E5%8F%AF%E4%BB%A5%E8%AE%A9%20apache%2Frewrite%20%E9%87%8D%E5%AE%9A%E5%90%91%20products%2F%20%E5%88%B0%20products.php.png)
我在使用两个不同的 Apache 服务器时遇到了问题。它们都是 2.2.x,所以次要版本不同。
在它们两个中我都有相同的 php 应用程序和这个 .htaccess:
重写引擎开启 RewriteCond %{REQUEST_FILENAME} -s [或] RewriteCond %{REQUEST_FILENAME} -l [或] RewriteCond %{REQUEST_FILENAME} -d 重写规则 ^.*$ - [NC,L] 重写规则^.*$ index.php [NC,L]
我的问题是,在服务器 A 中,当我访问 products/ 时,它会将我重定向到 products.php。
在服务器 B 中,当我访问 products/ 时,它会将我重定向到 index.php。这是正确且想要的行为。
由于两个服务器上的 modrewrite 规则相同,是否有其他指令可能会导致此问题?
谢谢!
答案1
尽管尾随斜杠没有意义,但是 mod_negotiation / Options Multiviews 很乐意将产品映射到与 mod_rewrite 完全正交的 products.php。
编辑:嗯,+ Options + Multiviews 上的 AcceptPathInfo 会给你 products/ -> products.php 并且 PATH_INFO 为“/”。