我有一个简单的重写规则,它的工作原理和预期一样好:
RewriteRule ^user/(\w+)/?$ user.php?id=$1我有一个php文件,文件有:
<?php echo $_GET['id']; ?>这在以下URL中运行良好,并且id被传递没有问题:
http://localhost/user?id=JoeUser
我知道mod_rewrite正在工作,因为这个url还将我发送到user.php:
http://localhost/user/JoeUser
但是,JoeUser从来没有实际超过1美元,我以前从未见过这种行为。是OS中的一个bug,还是我遗漏了什么?
发布于 2016-05-05 17:05:56
它是OS中的一个bug吗?
不,这不是窃听器。这是MultiViews选项的效果,默认情况下在Apache中启用该选项。选项MultiViews由Apache's content negotiation module使用,该选项在 mod_rewrite之前运行,并使Apache服务器与文件扩展名匹配。因此,/file可以在URL中,但它将服务于/file.php。
要关闭它,请:
Options -MultiViews
RewriteEngine On
RewriteRule ^user/(\w+)/?$ user.php?id=$1 [L,QSA,NC]https://stackoverflow.com/questions/37056006
复制相似问题