Redirect a user to a mobile version of a website

December 2016

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!

Related :

This document entitled « Redirect a user to a mobile version of a website » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.