• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 858
  • Last Modified:

htaccess mobile redirect to subdomain

I'm trying to redirect my website to m.website for mobile.

I get a "too many redirects" error with the following:

RewriteEngine On 

RewriteCond %{REQUEST_URI} !^/http://m.candpgeneration.com/.*$
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ /http://m.candpgeneration.com/ [L,R=302]

Open in new window

0
Kyle Hamilton
Asked:
Kyle Hamilton
1 Solution
 
Kyle HamiltonData ScientistAuthor Commented:
never mind I figured it out. there was an unnecessary slash in the rule:

the correct script:

RewriteEngine On 

RewriteCond %{REQUEST_URI} !^/http://m.candpgeneration.com/.*$
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ http://m.candpgeneration.com/ [L,R=302]
                                  

Open in new window

0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now