url 重写 "double path for same file"

url rewriting "double path for same file"

我的 htaccess 文件有问题,但我不明白错误从何而来:

例如:

我的文件夹中有以下文件

我做了这样的基本重写

 RewriteRule    ^about/$    contact.php [L]

所以现在可以从 http://localhost/project/about/

访问我的联系页面

问题是该页面也可以从

访问

为什么会这样? 我怎么能禁止呢?

感谢您的所有回答!

这是由于启用了选项 MultiViews。选项 MultiViewsApache's content negotiation module 使用,它运行 before mod_rewrite 并使 Apache 服务器匹配文件的扩展名。所以 /file 可以在 URL 中,但它会服务于 /file.php.

要禁止此操作,您可以在 .htaccess 顶部添加此行:

Options -MultiViews