【问题标题】:.htacces not working as long as there is a file with the same name只要有同名文件,.htaccess 就不起作用
【发布时间】:2014-04-22 16:48:39
【问题描述】:

我试图将一些子目录重定向到 php 中的处理器来处理请求。 基本上,这意味着我想将 www.myurl.com/members/Max 重定向到 urlprocessor.php?url=members/Max,所以我可以在那里处理它以获得我需要的成员数据。

我在我的 .htacces 中使用以下代码,它正在工作。

RewriteEngine on
RewriteBase /newboots
RewriteRule ^\.htaccess$ - [F]
RewriteRule ^members(.*)$ urlprocessor.php?url=$1 [L,QSA]

但是!一旦我的目录中有 members.php,我就会收到一些错误。 调用 /members/Max 仍然有效。 调用 /members 会导致一个空白页面。 调用 /members/ 会导致一个空白页面。 呼叫/成员。正在工作中 (甚至)调用 /members.php 正在工作

只要我将 members.php 重命名为 sometingelse.php,它就会再次正常工作。

我不明白:) 感谢您的帮助...

【问题讨论】:

    标签: apache .htaccess apache2


    【解决方案1】:

    我相信这是由于您的 Apache 中启用了选项 MultiViews。通过将此行放在顶部来禁用它:

    Options -MultiViews
    
    • 选项MultiViewsApache's content negotiation module 使用,它在mod_rewrite 之前运行,并使Apache 服务器匹配文件的扩展名。所以/file 可以在 URL 中,但它会服务于/file.php

    【讨论】:

    • 非常感谢!!修复了问题 - 我永远找不到这个 :-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-14
    • 1970-01-01
    • 1970-01-01
    • 2013-02-03
    • 2015-06-04
    • 1970-01-01
    相关资源
    最近更新 更多