我如何重定向到移动版网站的AMP版本?

编程入门 行业动态 更新时间:2024-10-25 22:36:22
本文介绍了我如何重定向到移动版网站的AMP版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 假设我有一个页面网站,它有两个版本,一个用于桌面的简单html文件和一个用于手机的Google AMP版本。我如何重定向到AMP版本?谢谢 解析方案

假设你的放大器版本在/ amp( example/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 - ] +)([\ /] *)$ example/$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 (example/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-]+)([\/]*)$ example/$1/amp [L,R=302]

更多推荐

我如何重定向到移动版网站的AMP版本?

本文发布于:2023-11-02 08:33:21,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   版本   网站   AMP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!