2015-03-31 69 views
1

我想将移动设备上的用户重定向到特定的登陆页面(而不是文件夹)。但它应该只是一个登陆页面。所以用户必须能够在网站上导航。我做了大量的研究和定制this的方法。不幸的是,它仍然不适用于移动设备。该网页甚至没有加载我的手机。仅将移动设备重定向到登录页面。但只有一次

# Check if this looks like a mobile device 
# (You could add another [OR] to the second one and add in what you 
# had to check, but I believe most mobile devices should send at 
# least one of these headers) 
RewriteCond %{HTTP:x-wap-profile} !^$ [OR] 
RewriteCond %{HTTP:Profile}  !^$ 

# Check to make sure we haven't set the cookie before 
RewriteCond %{HTTP:Cookie}  !\smredir=0(;|$) 

# Now redirect to the mobile site 
RewriteRule^http://example.com/mobilelandingpage [R,L] 


# Set cookie for mobile devices to make sure they will not get redirect to the landingpage again 
RewriteCond %{HTTP:x-wap-profile} !^$ [OR] 
RewriteCond %{HTTP:Profile}  !^$ 
# Set a cookie, and skip the next rule 
RewriteRule^- [CO=mredir:1:%{HTTP_HOST},S] 

任何人都可以帮我吗?非常感谢!对此,我真的非常感激。

回答

1

终于明白了!

# Check if this looks like a mobile device 
# (You could add another [OR] to the second one and add in what you 
# had to check, but I believe most mobile devices should send at 
# least one of these headers) 
RewriteCond %{HTTP:x-wap-profile} !^$ [OR] 
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR] 
# Check to make sure we haven't set the cookie before 
RewriteCond %{HTTP:Profile}  !^$ 
RewriteCond %{HTTP:Cookie}  !\smredir=0(;|$) 

# Now redirect to the mobile site 
RewriteRule ^/?$ http://domain.com/index.php/landingpage.html [L,R=302] 


# Set cookie for mobile devices to make sure they will not get redirect to the landingpage again 
RewriteCond %{HTTP:x-wap-profile} !^$ [OR] 
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR] 
RewriteCond %{HTTP:Profile}  !^$ 
# Set a cookie, and skip the next rule 
RewriteRule^- [CO=mredir:0:%{HTTP_HOST},S]