View previous topic :: View next topic |
Author |
Message |
lamina -
Joined: 25 Apr 2006 Posts: 20
|
Posted: Fri Apr 17, 2015 10:47 pm Post subject: Rewrite Rule for mobile |
|
|
Hi, I've been tryingto figure out a rewrite rule to redirect visitors to my sites automatically to a mobile site - with no joy - something like this:
RewriteEngine On
# Check for mime types commonly accepted by mobile devices
RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^ http://m.domain.com%{REQUEST_URI} [R,L]
and help would be appreciated
Richard |
|
Back to top |
|
|
lamina -
Joined: 25 Apr 2006 Posts: 20
|
Posted: Sun Apr 19, 2015 9:25 am Post subject: Solved! |
|
|
This worked a dream :
######### Begin - Redirect Mobile Browser Accessing /siteurltoredirect
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^siteurltoredirect$ http://theendpointurl.com [R,L]
########## End - Redirect Mobile Browser Accessing /siteurltoredirect
just save it as .htaccess and run it through the marvellous redirect tool.
The original website for this code is:
http://tech.pro/tutorial/1063/redirect-mobile-devices-using-htaccess
and if you wish toadd more user agents just include them in the ReWriteCond statement. |
|
Back to top |
|
|
|