Rewrite Rule for mobile

 
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting
View previous topic :: View next topic  
Author Message
lamina
-


Joined: 25 Apr 2006
Posts: 20

PostPosted: Fri Apr 17, 2015 10:47 pm    Post subject: Rewrite Rule for mobile Reply with quote

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 View user's profile Send private message
lamina
-


Joined: 25 Apr 2006
Posts: 20

PostPosted: Sun Apr 19, 2015 9:25 am    Post subject: Solved! Reply with quote

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 View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group