Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 如何在手机上自动将我网站的每篇帖子重定向到AMP版本?_Wordpress_.htaccess_Redirect_Amp Html_Auto - Fatal编程技术网

Wordpress 如何在手机上自动将我网站的每篇帖子重定向到AMP版本?

Wordpress 如何在手机上自动将我网站的每篇帖子重定向到AMP版本?,wordpress,.htaccess,redirect,amp-html,auto,Wordpress,.htaccess,Redirect,Amp Html,Auto,我想在手机上自动重定向我网站的每个帖子。我正在使用这个代码 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !/amp$ [NC] RewriteCond %{HTTP_USER_AGENT} (2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hipto

我想在手机上自动重定向我网站的每个帖子。我正在使用这个代码

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/amp$ [NC]
RewriteCond %{HTTP_USER_AGENT} (2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800) [NC]
RewriteRule ^([a-zA-Z0-9-]+)([\/]*)$ example.x/$1/amp [L,R=302]
您可以使用javascript 如果设备不是桌面。重定向到Amp版本

<script>
    var isMobile = window.orientation > -1;
    if(isMobile){
        window.location.replace("{{ url('aboutUsAMP') }}");
    };
</script>

var isMobile=window.orientation>-1;
if(isMobile){
replace(“{url('aboutsump')}}”);
};

我必须在每页上使用自动重定向。通过这种方法,我将不得不在每个不适用的页面上手动执行。