重定向无效,htaccess忽略我的IP

时间:2017-06-17 18:33:18

标签: .htaccess redirect mod-rewrite

这里是我的htaccess

RewriteEngine On
RewriteBase /

# Rewrite non-www to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Rewrite HTTP to HTTPS:
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Rewrite to comingsoon
RewriteCond %{REMOTE_ADDR} !=91.75.39.77
RewriteCond %{REQUEST_URI} !/comingsoon\.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css|js) [NC]
RewriteRule .* /comingsoon.html [R=302,L]

具有正确IP的访问者将被忽略并重定向。 代码出了什么问题,有人注意到了什么吗?

提前致谢。

1 个答案:

答案 0 :(得分:0)

好的做法     RewriteCond %{HTTP:X-FORWARDED-FOR} !=91.75.39.77