How to clear a 301 redirect that has already been stored in the browser cache?

Asked

Viewed 958 times

6

To make it easy to understand the problem, I will call the site that had the redirect "A" and the destination "B"

A 301 redirect (instead of 302) was carried out from site A to site B without any expiration date, since the server was not sending the "expires" headers, the users that accessed at the time continue to be redirected to site B, even with the redirect . htaccess removed (default behavior of a 301 redirect).

However the site A is well accessed and in the time it was this way, some users accessed. Luckily both domains are properties that we have access to, however we cannot create another redirect (even 302) from site B to site A, to invalidate the previous in browsers that have already cached.

This technique works, however the site B is also very accessed.

I wonder if there is any way to clear this redirection in browsers that have cached, without user intervention.

One possible solution was to detect if the site B was accessed by site A and manage it by some PHP script for example (creating a redirect back, only when it had originated from site A, creating a loop that invalidates the cache). However I could not find any variable that could determine that the site has been redirected and its origin was the site A.

Updated

I received some responses to invalidate the cache, they work, however I can’t let the B domain redirect to A to invalidate the cache, because both are different sites and well accessed.

Is there any solution to this problem?

  • The answer works for different websites, just the . htaccess is on the site that will be redirected, I explained in the comment, if your site B was invaded (I didn’t understand how it might have been hacked), so you can point his DNS to a new hosting, since you should have access to the data as CNAME in the donimio log. If you don’t have the data then the problem isn’t about programming, but yes with something judicial, you will have to contact who manages the domain and maybe open a case (do not understand of legal), but depends on what occurred...

  • ... Now this invasion story is that it’s too confusing, if it’s invaded the so-called invader can do whatever you want, or did you just lose access for another reason? Explain this better please.

1 answer

5


The redirect "cache" is in the client (browser or database searchers), what you have to do is move the new address pass to redirect to the old again.

Supposing first you move http://site/foo.html for http://site/baz.html:

RewriteEngine on
RewriteRule ^foo\.html$ baz.html [R=301,L]

The browser will store this (and the searchers like Google too), so if you want to re-disregard the "cache" (note: it has nothing to do with Cache-Control header) it will be necessary to move back by inverting Baz.html by foo.html, like this:

RewriteEngine on
RewriteRule ^baz\.html$ foo.html [R=301,L]

This goes even on different domain sites, the new site will need a .htaccess or have in your headers the steering back.

So probably the client going revalidate, of course if it is a browser I can not say that this occurs at all, if it happens then unfortunately the way is to clean the navigation data.

  • I imagined an old IE getting 301, then going to the cached address, taking 301 and going to another address, and so on until the computer fry or the cache is invalid

  • 1

    @Jeffersonquesado I will perform the test, I have an XP in an old netbook here :)

  • I tested on Windows 7, I can’t remember which version of IE, however it worked. It works with a 302 redirect too, the problem is that the domain that was redirected (destination) is also used, so I can’t leave it "off the air".

  • A comment outside my current problem, imagine if a site is hacked and redirected to another that the administrator does not have access to? Game Over? It is a somewhat problematic issue, especially when the main audience of this site is more lay.

  • @Renancavalieri as well "invaded"? You have access to the domain register (it has nothing to do with hosting), you can change the dns (type if it is a domain with .com.br go to https://registro.br) to point to a new hosting, a hosting can have several domains, you can solve everything in your current hosting, as long as both domains point to the same DNS. Then in rewritecond you check the domain.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.