.htaccess重写规则条件不起作用

时间:2014-09-22 23:10:54

标签: apache .htaccess mod-rewrite

我试图重写规则,但我无法找到正确的表达方式。我一直在寻找不同类型的正则表达式验证器,他们说这个表达式有效。

我的.htaccess如下所示:

Options +FollowSymlinks -MultiViews -Indexes
DirectoryIndex index.php index.html index.htm
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php(.+)=([a-zA-Z]+)&([a-z]+)=([a-zA-Z]+)&([a-z]+)=([a-zA-Z]+)&([a-z]+)=(.*)$ /$3+$5+$7 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

示例URI为:http://www.example.com/index.php?r=site/action&param1=value1

1 个答案:

答案 0 :(得分:1)

您无法在重写规则中与查询字符串匹配,您需要使用%{QUERY_STRING}%{THE_REQUEST}变量。

虽然我们完全不清楚你要做什么,但试试这样的事情:

Options +FollowSymlinks -MultiViews -Indexes
DirectoryIndex index.php index.html index.htm
RewriteEngine on
RewriteBase /

RewriteCond %{THE_REQUEST} \ /+index\.php\?(.+)=([a-zA-Z]+)&([a-z]+)=([a-zA-Z]+)&([a-z]+)=([a-zA-Z]+)&([a-z]+)=(.*)
RewriteRule ^ /%3+%5+%7 [L]
相关问题