Forum Topic: Looking for a simple Mobile redirect

Forum: .htaccess Forum : Redirecting • Posted by David Shantz • Updated:

We have developed a mobile version of a site, which we wish to redirect traffic from mobile devices (broadly) to.

Not worried too much about specific devices, would like to include Tablets and smart phones, Android and Apple. There is nothing specific in the book index about this important topic and I’m not smart enough to figure it out on my own…

Site:

http://www.coalign.com

Mobile redirect:

http://www.coalign.com/CoAlignMOBILE/index.html

HELP

The best I cold find was on StackOverflow… but it seems to be incomplete.

RewriteCond %{HTTP_HOST} ^www\.coalign\.com [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ http://www.coalign.com/CoAlignMOBILE/index.html/$1 [L,R=302]

Cheers

3 Replies to “Looking for a simple Mobile redirect”

Posted by Jeff Starr

Hi David,

For mobile redirects, I recommend using Mobile Detect, which is PHP-based and much more flexible and thorough than what can be achieved with .htaccess. Here is the link: https://mobiledetect.net/

An option if you want to use .htaccess instead would be to locate the list of mobile devices in the Mobile Detect script, and then format it for .htaccess. That would cover just about all devices via .htaccess.

Good luck!

Posted by David •

Please remove! Somehow this post was on top of the forum but old!

Posted by Jeff Starr

Please remove what, exactly?