这是一个很好的移动重定向javascript吗?或者我会被谷歌封杀

Is this a good mobile redirection javascript? Or will I get banned from google?

本文关键字:或者 谷歌 javascript 重定向 一个 移动 很好      更新时间:2023-09-26

我在网上找到了这个:

<script>//<![CDATA[    
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows'sce|palm/i.test(navigator.userAgent.toLowerCase()));    
var refUrl = document.referrer; // Get the URL where the user came from    
var prevUrl = refUrl.substr(7,23); // Create a substring after 'http://' and '.com'
var mobileUrl = "m.testsite.com"; // String from mobile site URL; must match prevUrl    
// Run auto-redirect only if the user is on mobile and isn't from m.testsite.com   
if ((mobile) && !(prevUrl == mobileUrl)) {        document.location = "http://m.testsite.com";    } //]]></script>

它工作得很好,但我以前没有见过这个,因此我担心这可能会导致谷歌的惩罚或禁止。你觉得呢?我应该把移动googlebot在useragent字符串?

谷歌现在非常聪明,它不需要一个糟糕的重定向就能把你列入黑名单。它很有可能知道你想做什么。而且,他们不会禁止你,除非你做了非常非常坏的事。在最坏的情况下,他们不会索引那个页面。