2013-04-20 59 views
0

我知道如何排除文件夹,文件类型,但我不知道如何排除包含特定单词的链接。 我有这样的规则:匹配并排除来自重写规则的链接

RewriteCond %{HTTP_HOST} ^www\.domain\.com 
RewriteRule (.*) http://en.domain.com/$1 [QSA,L] 

如何从这一规则排除有在开头的链接:一个index.php的管理=

回答

1

这应该做的伎俩:

RewriteCond %{HTTP_HOST} ^www\.domain\.com 
RewriteCond %{REQUEST_FILENAME} index\.php 
RewriteCond %{QUERY_STRING} !^a=admin 
RewriteRule (.*) http://en.domain.com/$1 [QSA,L] 

在这里,我们添加一个条件,指出只有在主机为www.domain.com,请求的文件为index.php,并且查询字符串不在a=admin时才会发生重写。

因此,www.domain.com/test将重定向到en.domain.com/test,但www.domain.com/index.php?a=admin根本不会重定向。

+0

上帝保佑你! – 2013-04-21 07:22:51

+0

不客气:) – 2013-04-21 07:58:31