我正在使用元标记来重定向我的Blogger页面,但重定向发生在旧Blogger之后,然后重定向发生。
有没有办法在没有的情况下重定向首先完全加载旧的Blogger页面?
我在模板的标题部分使用以下代码:
<meta content='0;URL='http://newsite.com' http-equiv='refresh'/>
答案 0 :(得分:0)
您应该在打开head标记后立即放置重定向代码。这种JS redirect code生成器可以帮助您处理这种情况。您不应该使用普通的HTML meta
重定向,而是使用这种一体化解决方案:
<!-- Pleace this snippet right after opening the head tag to make it work properly -->
<!-- This code is licensed under GNU GPL v3 -->
<!-- You are allowed to freely copy, distribute and use this code, but removing author credit is strictly prohibited -->
<!-- Generated by http://insider.zone/tools/client-side-url-redirect-generator/ -->
<!-- REDIRECTING STARTS -->
<link rel="canonical" href="http://newsite.com"/>
<noscript>
<meta http-equiv="refresh" content="0;URL=http://newsite.com">
</noscript>
<!--[if lt IE 9]><script type="text/javascript">var IE_fix=true;</script><![endif]-->
<script type="text/javascript">
var url = "http://newsite.com";
if(typeof IE_fix != "undefined") // IE8 and lower fix to pass the http referer
{
document.write("redirecting..."); // Don't remove this line or appendChild() will fail because it is called before document.onload to make the redirect as fast as possible. Nobody will see this text, it is only a tech fix.
var referLink = document.createElement("a");
referLink.href = url;
document.body.appendChild(referLink);
referLink.click();
}
else { window.location.replace(url); } // All other browsers
</script>
<!-- Credit goes to http://insider.zone/ -->
<!-- REDIRECTING ENDS -->
它具有搜索引擎支持,与所有浏览器兼容,并且避免重定向循环。