Redirect a user to a mobile version of a website

September 2017

Redirect your users to a mobile version of your website using htaccess

If you have a mobile version of your website, then it may be that you want to automatically redirect your visitors to the latter (each time they connect via theire mobile)
  • To do this there are several solutions, the simplest is to use the .htaccess file and write the following lines of code:

RewriteCond %{HTTP_USER_AGENT} "ipod|iphone|ipad|android|palm" [NC]    
RewriteRule (.*) [R=301,L]   
  • Here the mobile user are redirected to:
  • To change the domain name, simply edit the second line!


Published by jak58. Latest update on April 19, 2011 at 09:57 AM by jak58.
This document, titled "Redirect a user to a mobile version of a website," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (