如何在htaccess中修复错误的重定向utl 301?

时间:2017-02-20 02:26:31

标签: apache .htaccess varnish

我使用htaccess限制ip,可以连接到管理员和用户登录页面。

RewriteCond %{REMOTE_ADDR} !=127.0.0.1
RewriteRule (admin|user)$ http://redirect_example.com [R=301,L]

但问题是我使用了301重定向,这意味着我无法将网址http://redirect_example.com更改为其他网址。它已经缓存了。我的卷曲-I http://example.com/user结果:

HTTP/1.1 301 Moved Permanently
Date: Fri, 17 Feb 2017 03:46:19 GMT
X-Content-Type-Options: nosniff
Cache-Control: max-age=1209600
Expires: Fri, 03 Mar 2017 03:46:19 GMT
Content-Length: 313
Content-Type: text/html; charset=iso-8859-1
Location: http://redirect_example.com
Age: 251965
X-Cache: HIT
X-Cache-Hits: 56
Connection: keep-alive

如何将http://redirect_example.com更改为其他网址?

2 个答案:

答案 0 :(得分:2)

由Varnish引起。您应该通过运行命令禁止缓存:

varnishadm 

然后按域禁止缓存:

ban req.http.host ~ "redirect_example.com" 

答案 1 :(得分:1)

它只是在您的浏览器中缓存。清除浏览器缓存。您可以在测试时使用302重定向来帮助解决此问题。