2

我正在为移动用户设置指向移动登录页面的重定向,而我使用的脚本正在抛出 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。.
这会导致问题吗?

感谢帮助。

4

1 回答 1

1

你能试一下吗:

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]
于 2013-11-08T17:22:16.083 回答