2015-03-31 61 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]