簡體   English   中英

通過完整的網站鏈接重定向到移動網站

[英]Redirect to Mobile Site with Full Site Link

我正在為移動用戶設置到移動目標網頁的重定向,而我正在使用的腳本拋出了505。

整個htaccess代碼如下:(更新)

<FilesMatch "\.(html|htm|js|css)$">
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</IfModule>
</FilesMatch>

#MobileSetup
RewriteEngine On 
RewriteBase /

RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
RewriteRule ^ – [CO=mredir:0:http://www.maindomain.com]

RewriteCond %{HTTP_HOST} !^http://www.maindomain.com/mobile/\.com$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpg|css|png|gif)$ [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera         mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$) [NC]
RewriteCond %{HTTP_COOKIE}  !mredir=0 [NC]
RewriteRule ^ http://www.maindomain.com/mobile/? [R,L]

#Was at the top

RewriteEngine On 
RewriteBase /

RewriteRule ^news/([a-zA-Z0-9_-]+)$ /news.php?url=$1 [NC,L]

RewriteCond %{HTTP_HOST} ^maindomain.com$
RewriteRule ^(.*)$ http://www.maindomain.com$1 [R=301,L]

ErrorDocument 404 /404.php

#Redirects
Redirect 301 main site redirects

#10.28.13
Redirect 301 main site redirects

我試過調試,但無濟於事。 在服務器上設置了強制非www的重定向 www。
這會引起問題嗎?

感謝幫助。

你能試一下嗎:

RewriteEngine On 

RewriteBase /

RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
RewriteRule ^ – [CO=mredir:0:http://www.regularsite.com]

RewriteCond %{HTTP_HOST} !^mobile-site\.com$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpg|css|png|gif)$ [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$) [NC]
RewriteCond %{HTTP_COOKIE}  !mredir=0 [NC]
RewriteRule ^ http://mobile-site.com/? [R,L]

更新::您的完整.htaccess:

RewriteEngine On 
RewriteBase /

RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
RewriteRule ^ – [CO=mredir:0:http://www.maindomain.com]

RewriteCond %{REQUEST_URI} !\.(jpg|css|png|gif)$ [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$) [NC]
RewriteCond %{HTTP_COOKIE} !mredir=0 [NC]
RewriteRule !^mobile/ /mobile/? [R,L]

RewriteCond %{HTTP_HOST} ^maindomain.com$
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteRule ^news/([\w-]+)$ /news.php?url=$1 [NC,L,QSA]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM