大网数据广告活动
网站运营与故障问答

How can I 301 redirect back to a url that was previously 301 directed away from?

· 52CE 我爱测

The domain example.com had a 301 redirect set to go example.co.uk Now the decision has been made to use example.com as the main domain, so a 301 redirect is required from example.co.uk. But because the previous redirect is cached…

问题原文

原帖链接 · charliefortune · CC BY-SA 3.0

The domain example.com had a 301 redirect set to go example.co.uk

Now the decision has been made to use example.com as the main domain, so a 301 redirect is required from example.co.uk.

But because the previous redirect is cached everywhere, repeat visitors will end up in an infinite loop, as I did. I can empty my cache to make it work, but I can't empty theirs.

I have to go with 301's to preserve seo page rank.

The only solution I can think of is to add a new redirect from example.com to example.co.uk with an expiry date on. Hopefully this would overwrite the previous one that presumably has no expiry date. Then, after a suitable period of time when I think the site has been reindexed and the majority of visitors have returned, and the 301 has expired I could remove it and set up my new one from example.co.uk to example.com.

Does this sound like a possible strategy? If not, how does anyone ever get out of this hellish situation?

已采纳解答

原帖链接 · BillThor · CC BY-SA 3.0

You should add Cache-control headers to the 301 responses. Consider setting a short (1 day) expiry. Start tracking your 301 responses by site and URL to determine when the 301 response rates have stabilized. At that point you should be able to consider switching URLs. Remove the cache time, and wait that period. (301 rates should increase.)

This can be done as follows

RewriteCond %{HTTP_HOST} ^www.example.co.uk [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,NC,L,E=nocache:1]

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

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

Your company has painted itself into a corner by stating they will never use example.com as the domain with the 301 responses. If they haven't painted themselves into the corner with www.example.com, I would use that as a stepping stone. Browser caches can be extremely long lived, especially if clients have example.com bookmarked.

Redirecting to a different (never used) path should also work. This may impact your SEO rankings.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2016-08-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。