RewriteCond 不起作用

RewriteCond 不起作用

在我的 .htaccess 文件中

RewriteRule .* /test/index.php [L]

该代码在 ubuntu 服务器上的 apache2 上运行良好。

但是当我添加这一行

RewriteCond %{QUERY_STRING} foo

它不起作用。它在 Windows 上的 WAMP 上运行良好

Linux ip-172-31-21-17 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

服务器版本:Apache/2.4.7 (Ubuntu)

答案1

6 小时后我找到了解决方案。有人能帮我解释一下为什么会这样吗

经过 6 小时的研究,我使用命令启用了 a2enmod,sudo a2enmod rewrite然后再次尝试启用重写。这次幸运的是我错过了sudo,它开始工作了。

真让人困惑 :(

相关内容