我的.htaccess文件有3个重写规则,但我面临重定向问题:
_not_analyzed
问题是如果阻止的IP尝试在维护时访问该站点,我会收到"不正确的重定向"错误。如果IP是被拒绝的ips之一,如何停止重写处理?
答案 0 :(得分:1)
您可以使用:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} =IP TO BLOCK GOES HERE
RewriteCond %{REMOTE_ADDR} =ANOTHER IP TO BLOCK GOES HERE
RewriteCond %{REQUEST_URI} !^/blocked
RewriteRule ^ http://www.myhost.com/blocked [R=307,L]
RewriteCond %{REMOTE_ADDR} !=AUTHORIZED IP HERE
RewriteCond %{REQUEST_URI} !^/(?:maintenance|blocked)
RewriteRule ^ http://www.myhost.com/maintenance [R=307,L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
ErrorDocument 400 /400.php
ErrorDocument 401 /401.php
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
ErrorDocument 500 /500.php