从移动设备重定向到特定页面的特定页面

时间:2018-08-30 21:35:44

标签: wordpress .htaccess url-redirection http-redirect

我一直在这里查看此答案,如果检测到用户正在使用移动设备,似乎可以重定向到页面。

但是,如果我们可以检测到用户在移动设备上,是否可以重定向到特定的URL?来自.htaccess文件

请注意,我正在执行HTTPS。

例如

  • 如果is_mobile && is_page“商店”-重定向至“ mobileshop”
  • 如果是移动设备,并且是页面“主页”-重定向到“ mobilehome”

似乎您可以使用this将特定域重定向到页面...但不确定如何将其应用于仅在设备移动时触发?

    RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www.\.)?urlnumberone\.com
RewriteRule ^$ /thepath/tomypage/goeshere/ [L]

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www.\.)?urlnumbertwo\.com
RewriteRule ^$ /thesecond/pathgoeshere/ [L]

1 个答案:

答案 0 :(得分:0)

您可以为此使用Javascript代码

<script type="text/javascript">
<!--
if (screen.width <= 699 ) {
    if(window.location.pathname == '/strongshop')
    {
        document.location = "/strongshopmobile";
    }
}
//-->
</script>

您以后可以将其与“自定义”字段或编程逻辑结合使用,以使其更加高级和动态

相关问题