【问题标题】:htaccess to Redirect users to mobile site BUT still allow requests from the mobile sitehtaccess 将用户重定向到移动站点但仍然允许来自移动站点的请求
【发布时间】:2013-01-04 15:07:01
【问题描述】:

我在我的 htaccess 中使用以下 sn-p:

# redirect phones/tablets to mobile site
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{HTTP_HOST} !mobile\.website\.com [NC]
RewriteRule ^(.*)$ http://www.mobile.website.com/$1 [L,R=302]

但是,在我的移动应用程序中,我向 www.website.com/mobile 发出 AJAX 请求,但它们都失败了。如何发送这些 AJAX 请求并仍然重定向它们?

【问题讨论】:

    标签: apache .htaccess mobile redirect


    【解决方案1】:

    你可以使用:

    RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
    RewriteCond %{HTTP_HOST} !mobile\.website\.com [NC]
    RewriteCond %{REQUEST_URI} !^/mobile [NC]
    RewriteRule ^(.*)$ http://www.mobile.website.com/$1 [L,R=302]
    

    它将解锁 /mobile 并且您的 ajax 请求将起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-02
      相关资源
      最近更新 更多