我如何重定向到移动版网站的AMP版本? [英] How can i redirect to AMP version of website on mobile?
本文介绍了我如何重定向到移动版网站的AMP版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设你的放大器版本在/ amp( http://example.com/amp ),
,您可以尝试像下面这样在您的.htaccess文件中重定向访问者:
RewriteEngine On
RewriteCond%{REQUEST_URI}!/ amp $ [NC]
RewriteCond%{HTTP_USER_AGENT}(android | blackberry | googlebot\-mobile | [移动| iphone | ipod | \#opera \ mobile | palmos | webos)[NC]
RewriteRule ^([a-zA-Z0-9 - ] +)([\ /] *)$ https://example.com/$1/amp [L,R = 302]
Let's say i have one page website and it has two versions, one simple html file for desktops and one Google's AMP version for mobiles. How can i redirect to AMP version? Thanks
解决方案
Assuming your amp version is under /amp (http://example.com/amp), you can try redirecting your visitors in your .htaccess file like this:
RewriteEngine On
RewriteCond %{REQUEST_URI} !/amp$ [NC]
RewriteCond %{HTTP_USER_AGENT} (android|blackberry|googlebot\-mobile|iemobile|iphone|ipod|\#opera\ mobile|palmos|webos) [NC]
RewriteRule ^([a-zA-Z0-9-]+)([\/]*)$ https://example.com/$1/amp [L,R=302]
这篇关于我如何重定向到移动版网站的AMP版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文