Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex htaccess重定向IP,查询字符串异常除外_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Regex htaccess重定向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

我将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

其中哈希值总是在变化。通常,我会使用
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]