Skip to content Skip to sidebar Skip to footer

Detecting A 301 Redirect Using Client Side Code Only

I have a site which is no longer going to be used as the product is no longer being developed. This site will use a 301 redirect to direct any visits to the new product site. What

Solution 1:

This is not possible as-is. If you return a 301, the browser will follow it, and not display any HTML you may have sent.

Alternatively, you could return 200, along with the following:

<div>The new site is at newsite.com</div><scripttype="text/javascript">setTimeout(function() { window.location('newsite.com'); }, 60 * 1000);
</script>

This displays the div and redirects the user (after 60 seconds) but won't inform search engines that the content has been moved to the new site.

You can (somewhat) alleviate SEO woes with rel="canonical", but Google et al. recommend against it (your situation is what 301's were made for, rel="canonical says "There are two versions of this content, only index the one over here):

<head><linkrel="canonical"href="newsite.com"></head><body><div>The new site is at newsite.com</div><scripttype="text/javascript">setTimeout(function() { window.location('newsite.com'); }, 60 * 1000);
  </script></body>

Solution 2:

I suppose, no:

transparently follow the redirect

w3:xhr

Post a Comment for "Detecting A 301 Redirect Using Client Side Code Only"