appcropolois
  •  Templates
  • Builder
    •  Product Tour
    •  Sign up
    •  Dashboard
  •  Learn
  •  Discover
  •  Upgrade
  •  Sign in
  •  My Profile
    • View Orders
    • Edit Profile
    • Sign Out
  •  Cart
    ➜ 
  1. Home
  2. Learn
  3. Redirect iPhone and Android ...
Share

Redirect iPhone and Android Phones to a Mobile Website

A very easy way to redirect users that visit your website from a mobile device to the mobile version of your website, is using your htaccess file. If your server is running on Apache, you can add the following code to your .htaccess file to get the job done:

1
2
3
4
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "iphone|ipod|android" [NC]
RewriteCond %{HTTP_HOST} !^m.example.com
RewriteRule ^(.*)$ http://m.example.com/ [L,R=302]
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "iphone|ipod|android" [NC]
RewriteCond %{HTTP_HOST} !^m.example.com
RewriteRule ^(.*)$ http://m.example.com/ [L,R=302]

 

You can include other mobile browsers by adding other browser to the RewriteCond rule:

1
2
3
4
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{HTTP_HOST} !^m.example.com
RewriteRule ^(.*)$ http://m.example.com/ [L,R=302]
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{HTTP_HOST} !^m.example.com
RewriteRule ^(.*)$ http://m.example.com/ [L,R=302]

 

 

By: Raul Sanchez
Categories: Blog, Web Technology
Posted on: Wednesday, January 30, 2013

Sign in to post your comment


Not registered? Create an Account.

Lost your password? Click here to recover.

9 comment


Trina
Trina Tuesday 5th, February 2013 - 10:21:01 PM

Greetings! Very useful advice in this particular article! It's the little changes which will make the most significant changes. Many thanks for sharing!

Google
Google Wednesday 6th, January 2016 - 07:34:03 PM

Google Sites of interest we've a link to.

Google
Google Friday 8th, January 2016 - 02:14:16 AM

Google That may be the finish of this write-up. Right here you’ll uncover some web-sites that we believe you will appreciate, just click the links.

Google
Google Tuesday 22nd, August 2017 - 01:32:35 AM

Google Just beneath, are many totally not connected web-sites to ours, nonetheless, they're certainly really worth going over.

Google
Google Monday 20th, November 2017 - 03:53:00 PM

Google Always a large fan of linking to bloggers that I like but do not get a lot of link enjoy from.

Google
Google Friday 13th, September 2019 - 11:42:41 AM

Google That is the end of this article. Here you will discover some web pages that we assume you will value, just click the links.

Google
Google Sunday 15th, September 2019 - 10:02:49 PM

Google Here is an excellent Blog You might Come across Fascinating that we encourage you to visit.

Google
Google Saturday 23rd, January 2021 - 12:42:32 PM

Google Every when inside a even though we pick blogs that we read. Listed below are the most recent web-sites that we pick out.

Google
Google Saturday 30th, January 2021 - 06:39:19 PM

Google Here is a superb Blog You may Find Exciting that we encourage you to visit.

Building Apps?

Create, customize, and publish mobile web applications using the Appcropolis Mobile Builder.

Get Started
Browse Categories
  • Books (0)
  • CSS3 (2)
  • Design (0)
  • Frameworks (10)
  • How-To (6)
  • HTML5 (2)
  • jQuery Mobile (7)
  • Miscelaneous (1862)
  • Mobile Builder (1)
  • News (9)
  • Opinion (1)
  • User Experience (0)
  • Web Technology (11)
  • Webclips (4)

Ready-to-use Templates

Check out Appcropolis Mobile Templates

We offer 1,000's of mobile templates that are fully designed, coded, and ready to use. Learn more.

Download Free Templates

Contact Us

Your feedback means the world to us.
Contact us if you have any questions or
any feature requests:

Saint Louis, MO 63101
911 Washington Ave
Email: info@appcropolis.com

Appcropolis

  •   About Us
  •   Blog
  •   Discover
  •   Templates
  •   Contact Us

Get Free Templates

Subscribe to our newsletter to receive
notification about new templates, prodcut updates,
and technical articles.


© 2025 Appcropolis, LLC · All Rights Reserved
Sitemap  ·  Terms Of Service  ·  Privacy