Redirect a user to a mobile version of a website

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!

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
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 (