摆脱301重定向

时间:2012-05-11 15:46:57

标签: apache .htaccess mod-rewrite redirect http-status-code-301

我在.htaccess中编写了错误的301重定向

由于它是永久性的,我的浏览器/代理总是将我重定向到假地址,即使我在.htaccess中更改了重定向位置地址

如何摆脱这种旧的/错误的301重定向?

设置清楚:我知道如何使用mod_rewrite在.htacces中301。我想un-301

2 个答案:

答案 0 :(得分:1)

这不依赖于您的服务器配置,因为浏览器/代理决定查询您的网页或使用缓存重定向。您应该在您正在谈论的浏览器/代理中清理(或关闭)缓存。如果您不能这样做,请等到缓存超时(取决于代理设置)到期。

答案 1 :(得分:1)

可以使用htaccessmod_redirectmod_header中完成。

神奇的是,你可以在Rewrite中使用[E]修饰符设置一个环境变量,如果设置了environtment variabel,则设置非缓存标题。

这是代码

RewriteCond %{HTTP_HOST} !^mark\.koli\.ch [NC]
## the [E=nocache:1] modifier sets the environment variable "nocache"
RewriteRule ^/(.*)$ http://mark.koli.ch/$1 [R=301,L,E=nocache:1]

## Set the response header if the "nocache" environment variable is set
## in the RewriteRule above.
Header always set Cache-Control "no-store, no-cache, must-revalidate" env=nocache

## Set Expires too ...
Header always set Expires "Thu, 01 Jan 1970 00:00:00 GMT" env=nocache

Mark S. Kolich

中感谢blog entry

当然,这应该在 之前完成重定向。因此,在此之后,每个301重定向都不会被缓存,并且可以在没有模糊的情况下进行更改。

也许甚至可以通过apache_setenv使用PHP设置环境变量。

相关问题