I am redirecting an old blog to a new one with a combination of Javascript and evil http-equiv meta tag. In order to prevent duplication in robots I have also added:
<meta name="robots" content="noindex" />
The redirect snippets are as below:
开发者_如何转开发<!--Execute javascript rediect-->
<script type="text/javascript"><!--//--><![CDATA[//><!--
var url = "http://new_loc.blogspot.com/"
(document.images) ? location.replace(url) : location.href = url;
//--><!]]>
</script>
<!--If the browser can be bothered to refresh with new content,
also works if browser has javascript disabled, in mozilla family -->
<meta http-equiv="refresh" content="0;URL=http://new_loc.blogspot.com/" />
This however redirects deep-links to the front page of the new_loc which can be disorienting for the incoming reader. I would like the relative link to remain unchanged for both the javascript and http-equiv tricks. What would be the best way to achieve this ?
how about similar script for redirect to new url using javascript:
<script>
var myUrl = location.href;
var old = /http:\/\/old_loc.blogspot.com/gi;
var new1='http://new_loc.blogspot.com';
myNewUrl = myUrl.replace(old, new1);
window.location = myNewUrl;
</script>
or even Short CUT:
<script>
var old = /http:\/\/old_loc.blogspot.com/gi;
var new1='http://new_loc.blogspot.com';
window.location = window.location.href.replace(old, new1);
</script>
精彩评论