我在网上找到了这个:
<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 吗?