I am having some issue with the .htaccess file on one of my sites.
The error I get is that I'm trying to redirecting too many times.
The way it currently works is that I need to redirect the URL to the subfolder /dist
everytime I'm on desktop, and if I'm on mobile, I need to go to the mobile version of the website instead which is a subdomain starting with mobile.
my htaccess file looks like this:
RewriteEngine on
RewriteBase /
# Check if this is the noredirect query string
RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:www.mywebsite.com/dist]
RewriteCond %{HTTP_HOST} ^mywebsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mywebsite\.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "http\:\/\/www\.mywebsite\.com\/dist" [R=301,L]
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
# Can not read and write cookie in the same request, must duplicate condition
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$)
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC]
# Now redirect to the mobile site
RewriteRule ^ http://mobile.mywebsite.com [R,L]
can anybody help?
this is my first attempt at something like this
thanks