0

I'm using .htaccess to redirect mobiles using code found here RewriteCond to exclude a path not working I've tried rewriting the part that excludes path to exclude a URL but can't get it to work. Basically, i have a second url used on my hosting account which is an addon domain and is stored in a subfolder of my public html folder. My other website is stored on the public html folder with the .htaccess to redirect to a subdomain for mobile for that website.

Any suggestions on how i can stop the addon domain redirecting to the mobile version of the main website?

# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# Check if mobile=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)mobile=1(&|$)
RewriteRule ^ - [CO=mobile:1:%{HTTP_HOST}]

# Check if mobile=0 is set and set cookie 'mobile' equal to 0   
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [CO=mobile:0:%{HTTP_HOST}]

# Skip next rule if mobile=0 [OR] if it's a file [OR] if /path/    
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$) [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_URI} ^.*/path/.*$
RewriteRule ^ - [S=1]

# Check if this looks like a mobile device
RewriteCond %{HTTP_PROFILE}       !^$ [OR]
RewriteCond %{HTTP_X_WAP_PROFILE} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST}          !^m\.
# Check to make sure we haven't set the cookie before  
RewriteCond %{HTTP_COOKIE}        !mobile=0(;|$)
# Don't redirect "path" pages
RewriteCond %{REQUEST_URI} !^.*www.addondomain.com/.*$ [NC]
# Now redirect to the mobile site
RewriteRule ^ http://m.example.com/ [R,L,NC]
Community
  • 1
  • 1
Juicy
  • 55
  • 5
  • you need to provide us with the actual code you have tried.so far, your question is guesswork – Amit Verma Dec 08 '15 at 12:42
  • ok, just added the current code i've tried. Have tried a few different versions of fitting the www.addondomain.com in that space – Juicy Dec 08 '15 at 13:01

1 Answers1

0

Add that below RewriteBase /:

RewriteCond %{HTTP_HOST} ^(www\.)?addondomain\.com$ [NC]
RewriteRule ^ - [L]

Indicating to do nothing for addondomain.com

Croises
  • 18,570
  • 4
  • 30
  • 47