javascript - Detecting a 301 Redirect using Client Side Code Only -
i have site no longer going used product no longer being developed. site use 301 redirect direct visits new product site.
what show div first visits old site explain product name change visit old site first.
is possible using only javascript? read possible solutions using php again need js solution, if possible @ all.
note: using jquery 2.1 on site jquery solution fine.
this not possible as-is. if return 301, browser follow it, , not display html may have sent.
alternatively, return 200, along following:
<div>the new site @ newsite.com</div> <script type="text/javascript"> settimeout(function() { window.location('newsite.com'); }, 60 * 1000); </script> this displays div , redirects user (after 60 seconds) won't inform search engines content has been moved new site.
you can (somewhat) alleviate seo woes rel="canonical", google et al. recommend against (your situation 301's made for, rel="canonical says "there 2 versions of content, index 1 on here):
<head> <link rel="canonical" href="newsite.com"> </head> <body> <div>the new site @ newsite.com</div> <script type="text/javascript"> settimeout(function() { window.location('newsite.com'); }, 60 * 1000); </script> </body>
Comments
Post a Comment