Website Mobile Redirection Using .htaccess Script

Here is a simple way to redirect visitors to the mobile version of your website using .httaccess. Read and learn .htaccess redirection tutorial on mobile devices.┬áThis website .httaccess trick is pretty useful if your site visitor is currently using a mobile phone to browse on your site. While sometimes navigating to a site which has no mobile version is pretty discouraging as you have to continually zoom in or zoom out, depending on the site’s navigation bars and size of text, this .httaccess script might do the trick.

Note that this method is used if you already have a current mobile version of your website. Read on and learn how to use this .htaccess script to redirect your mobile visitors to your mobile version of your site.

htaccess

Steps by step method for mobile redirection using .htaccess script

1. Open your .httaccess file. (If you do not have an existing one, you could create it. Open a text editor and save it as .htaccess.)

2. Copy and paste the code below to your .htaccess file. (Change m.yourwebsite.com to your mobile website url.)

RewriteEngine On
 RewriteCond %{HTTP_USER_AGENT} (mobile|android|blackberry|brew|cldc|docomo|htc|j2me|micromax|lg|midp|mot|motorola|netfront|nokia|obigo|openweb|opera.mini|palm|psp|samsung|sanyo|sch|sonyericsson|symbian|symbos|teleca|up.browser|vodafone|wap|webos|windows.ce) [NC]
 RewriteRule ^(.*)$
 http://www.m.yourwebsite.com [R=302,L]

3. Save your .htaccess file.

4. Test it using your mobile phone.

If steps are done correctly, you now should be able to see the mobile version of your website. Setting up a mobile version of your website is a good trick in boosting traffic to your site. With the help of technology, more and more people now browse on the mobile devices, and using this trick will certainly help you and your visitors as well. Hope this website mobile redirection using .htaccess script helped you somehow.