首页 > 解决方案 > 带有查询字符串的 Apache 2.4 .htaccess RewriteRule

问题描述

我已经尝试将 apache 从 2.2 更新到 2.4,毕竟我有问题让网站的某些部分在新的 apache 上工作。我有搜索功能,htaccess 看起来像

RewriteEngine on

RewriteCond %{QUERY_STRING} ^q=(.*)$
RewriteRule ^search$ index.php?mode=search&q=%1&type=videos [QSA,L]

RewriteCond %{QUERY_STRING} ^q=(.*)$
RewriteRule ^search/photos$ index.php?mode=search&q=%1&type=photos [QSA,L]

RewriteRule ^search$ search.php [QSA,L]

我在哪里犯错?在 apache 2.2 上,这条线工作正常,但在 2.4 上是空白页,日志中没有错误。

标签: apache.htaccessmod-rewrite

解决方案


问题已修复,默认启用 apache 2.4 MultiViews,这是造成问题的原因。禁用MultiViews后,搜索和重写按预期工作。


推荐阅读