htaccess 301重定向-如何禁用它? [英] htaccess 301 redirect - how to disable it?

查看:117
本文介绍了htaccess 301重定向-如何禁用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我错误地在我的网站上添加了301重定向(因为我正在进行维护).现在,许多人无法回到我的网站,因为他们仍然被重定向到其他页面-尽管我删除了重定向(甚至删除了htaccess).我搜索的内容之所以多,是因为htaccess(或301重定向)已缓存在用户浏览器中,而我却找不到任何解决方案.有什么办法可以解决这个问题,我不能因为这样的事情而失去数百名访客?

I have added 301 redirect on my website by mistake (because I was doing maintenance). Now lots of people can't get back to my website, because they are still redirected to other page - eventhough I removed redirection (even deleted htaccess). As much as I searched around it's because htaccess (or 301 redirect) is cached in users browser and I wasn't able to find any solution for this. Is there any way to fix this, I can't just loose hundreds of visitors because of something like this?

推荐答案

此页面详细介绍了正在发生的事情:

This page explains what is going on in good detail:

基本上,现代浏览器会将重定向响应缓存301一段不确定的时间,并且不会向您的旧网页提出更新请求来刷新它.用户可以手动清除缓存,由于它是缓存,因此如果浏览器需要更多空间来存储其他数据(如其他重定向),则可以清除数据.

Basically, modern browsers cache the redirect response for 301 for some indeterminate amount of time and will not make an updated request to your old web page to refresh it. Users can manually clear the cache and, because it is a cache, data can be purged if the browser needs more space for other data (like other redirects).

此SuperUser问题从客户端解决了缓存问题:

This SuperUser question resolves the caching issue from the client's end:

一个有趣的答案是:

在此答案中,用户指出浏览器将 http://example.com/ http://example.com/?视为两个不同的网址.您可以转到新"站点并设置HTTP 302重定向,该重定向指向原始页面,结尾处带有?,并且该页面应加载.如果他们的原始页面已经有查询作为URL的一部分,则可以简单地在末尾添加& 以获得相同的结果.

In this answer, the user points out that the browser treats http://example.com/ and http://example.com/? as two different URLs. You could go to the "new" site and setup an HTTP 302 redirect pointing back to the original page with a ? on the end and it should load. If they original page already had a query as part of the URL, you can simple add an & to the end to achieve the same result.

这并不完美-毕竟是一个不同的URL-但至少他们可以查看您的旧站点.

It's not perfect -- it is a different URL after all -- but at least they'll be able to view your old site.

请注意,您的Web应用程序可能会尝试将空查询或无效查询重定向回干净"页面,您可能必须禁用该页面才能获得预期的结果.

Note that your web application may try to redirect empty queries or invalid queries back to a "clean" page, which you may have to disable to get the intended result.

更新
另一种选择是将重定向从新站点放回旧站点(将其重定向为302或307以避免您当前遇到的301问题).根据我的测试,Chrome会在执行此操作时删除旧的重定向.它可能会引发重定向循环"错误,但只有一次.我无法使用最新版本的Firefox完全重现缓存的重定向问题.其他浏览器的行为可能会不一致.

UPDATE
One other option is to put a redirect from the new site back to the old site (make this a 302 or 307 redirect to avoid the 301 problem you're currently having). From my testing, Chrome will remove the old redirect when it does this. It may throw a "redirect loop" error, but only once. I was unable to reproduce the cached redirect problem at all with the latest version of Firefox. Other browsers' behavior is probably going to be inconsistent.

这篇关于htaccess 301重定向-如何禁用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆