简体   繁体   中英

Redirect to Mobile Site with Full Site Link

I'm working on setting up a redirect to a mobile landing page for mobile users and the script I'm using is throwing up a 505.

Entire htaccess code is below: (Updated)

<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

I've tried debugging this but to no avail. There is a redirect set up on the server that is forcing a non-www. to go to the www. .
Could this be causing an issue?

Thanks for help.

Can you try:

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]

UPDATE:: Your full .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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM