Regex htaccess重定向IP,查询字符串异常除外
我将IP重定向到我的域:Regex htaccess重定向IP,查询字符串异常除外,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,我将IP重定向到我的域: RewriteCond %{HTTP_HOST} ^100\.100\.100\.100 RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301] 我想添加一个例外,该查询字符串不会重定向到域: index.php?option=com_notify&task=Send_Mail&hash=4dd2c2c208098797546c5bf0a858b185b564cf23 其中哈希值总是在变化。通常,我会使用Rewrit
RewriteCond %{HTTP_HOST} ^100\.100\.100\.100
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
我想添加一个例外,该查询字符串不会重定向到域:
index.php?option=com_notify&task=Send_Mail&hash=4dd2c2c208098797546c5bf0a858b185b564cf23
其中哈希值总是在变化。通常,我会使用RewriteCond
在查询字符串上重定向,并与RewriteRule
匹配
RewriteCond %{QUERY_STRING} ^option=com_notify&task=Send_Mail&hash=(.*)$ [NC]
RewriteRule ^index\.php$ http://www.mysite.com/whatever? [R=301,NE,NC,L]
但我不知道我该如何把它作为一个例外。总而言之,我希望IP地址100.100.100.100重定向到主站点,除非您有
100.100.100/index.php?option=com\u notify&task=Send\u Mail&hash=.*
只需在RewriteCond
中使用否定,如下所示:
RewriteCond %{HTTP_HOST} ^100\.100\.100\.100$
RewriteCond %{QUERY_STRING} !^option=com_notify&task=Send_Mail&hash= [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]