htaccess将多个移动页面重定向到多个页面 - 重定向无效

时间:2016-05-11 03:27:54

标签: .htaccess

我要做的是将网页重定向到移动网页。例如,通过www.domain.com/*进入的所有内容都会转到一个页面,然后进入特定页面(或一对)的任何内容都会转到另一个页面。

我以为我已经弄明白了,但在测试过程中,我遇到了各种各样的问题,所以我想我会发布我的htaccess文件,看看我在哪里。

RewriteEngine On
RewriteCond %{HTTP_HOST} ^ourdomain.com [NC]
RewriteRule ^(.*)$ http://www.ourdomain.com/$1 [L,R=301]
RewriteRule http://www.ourdomain.com/index.html http://www.ourdomain.com/ [L,R=301]
RewriteRule http://ourdomain.com/index.html http://www.ourdomain.com/ [L,R=301]
RewriteRule http://www.ourdomain.com/index.htm http://www.ourdomain.com/ [L,R=301]
RewriteRule http://ourdomain.com/index.htm http://www.ourdomain.com/ [L,R=301]

# This is where I have added code to redirect mobile users- not working
# Goal is anyone coming into all pages with the exception of the xselling
# and yselling pages needs to go to mobile_index. Mobile users coming in
# through xselling and yselling would go to mobile_index_sell.
# Side note we want PC and iPad users to go to non-mobile pages.
#
# Begin Mobile Page Redirects
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^index\.html$ /mobile_index.html [L,R=302]
RewriteRule ^xselling\.htm$ /mobile_index_sell.html [L,R=302]
RewriteRule ^yselling\.htm$ /mobile_index_sell.html [L,R=302]
# END Mobile redirect

ErrorDocument 404 http://www.ourdomain.com/
AddType text/html .shtml
AddHandler server-parsed .shtml
AddHandler server-parsed .html .htm .shtml
Options Indexes FollowSymLinks Includes

显然,如果你看到其他更好的方法让我知道。除移动线路外,htaccess本身对我们来说完美无缺。此外,我们尝试了PHP重定向,但它也起作用,但它对我们的Google Analytics和HitLinks产生了负面影响。

0 个答案:

没有答案