How to automatically redirect visitors to your mobile website

So how do you automatically detect and then redirect your user to either you mobile site or your main site?

It is very simple; the first thing to do is decide which mobile phones and tablets you are going to deal with. I would suggest you focus on the main 4 mobile phone operating systems and ignore the older ones as they are not worth the extra hassle. Tablets can also be ignored as they should be able to cope with your main site – unless you use flash and it’s an apple tablet.

The four main Mobile phones operating systems are Android, Blackberry, iOS (Apple), Windows and WebOS (HP/Palm).

To implement the automatic redirect follow the steps below

1. Login into your web host via FTP and locate the root directory on your web server, this  is normally where your index.htm file is located.

2. Look for a file called “.htaccess”.
If the “.htaccess” file is missing then create a blank file in notepad and use that. Remember the filename is just “.htaccess” there is no extension.

3. Edit either the “.htaccess” file you downloaded or the new file you created and add the following lines.
• RewriteCond %{REQUEST_URI} !^/ MOBILELOCATION /.*$
• RewriteCond %{HTTP_USER_AGENT} “android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile” [NC]
• RewriteRule ^(.*)$ / MOBILELOCATION / [L,R=302]

** change “MOBILELOCATION” with the location of your mobile site.

4. Save your edited file and upload it to the root directory and test.

Remember to backup your old htaccess file before uploading your new one encase anything goes wrong.

If you need anymore information or help then please leave a comment below.