We have a mobile site that is served using multiple domains. We want to redirect users who are using desktop user agents to our desktop sites while preserving the original domain the user used to access the site.
There seem to be a few .htaccess variables that can provide the domain but they include the subdomain as well. My current code is:
RewriteCond %{HTTP_HOST} ^m\. [NC]
RewriteCond %{HTTP_USER_AGENT} !(android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera\smobile|palmos|webos) [NC]
RewriteRule ^.*$ http://www.example.com/%{REQUEST_URI}/ [R=301,L]
This works fine, but we want to be able to adjust the domain to be the domain the request rather using than a static domain (example.com).
Is there a way to accomplish this with .htaccess? Thanks!