【问题标题】:htaccess redirect exception fails and can't figure why...?htaccess 重定向异常失败,无法弄清楚为什么......?
【发布时间】:2015-06-11 22:41:22
【问题描述】:

从我们客户的网站 (http://www.cfm33.com/),我们需要将所有移动设备重定向到移动网站 (http://m.cfm33.com/),这很有效。

但我们确实需要为预订页面设置一个例外,以便即使在移动设备上的用户也能被重定向到桌面网站的这个预订页面。

这是 .htaccess 中的内容:

## Mobile redirect
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} iPhone|Android|iPad|iPod|Blackberry
RewriteCond %{REQUEST_URI} !(\.jpg|\.jpeg|\.png|\.gif|\.svg)$ [NC]
RewriteCond %{REQUEST_URI} !reservation-formation.html [NC]
RewriteRule .* http://m.cfm33.com/ [R]
## End mobile redirect

知道为什么异常不起作用吗?我们已经尝试了几个小时,但仍然没有任何线索......

有什么想法吗?这可能与桌面站点上的一些自定义路由有关吗?

谢谢

大卫

【问题讨论】:

  • 不确定是否相关,但请尝试在.html (\.html) 中转义.

标签: .htaccess redirect url-rewriting


【解决方案1】:

试试这个规则:

## Mobile redirect
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} iPhone|Android|iPad|iPod|Blackberry
RewriteCond %{THE_REQUEST} !/reservation-formation\.html [NC]
RewriteRule !\.(jpe?g|png|gif|svg)$  http://m.cfm33.com/ [R]
## End mobile redirect

REQUEST_URI 替换为THE_REQUEST,因为其他规则可能会影响REQUEST_URI,而THE_REQUEST 保持不变。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-15
    • 1970-01-01
    • 2016-09-27
    • 2014-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多