We learn How Mobile Website Redirect From Desktop Website

Now a days so many people are using many variety mobile phone, smart phones and tablets. Its new thing for web designers and new challenge for developer to make your site compatible for mobile screens also. Your site is in two versions one is desktop/laptops or other is mobile. Many web developers use different types of technology to detecting and redirecting mobile users.

You May Also Like:

Here we learn different methods to mobile website redirect javascript.

When we open some websites on mobiles it will not made for mobile, smartphones or tablet screens these sites lose their mobile users. There are many ways to mobile website redirect.Below you can see Code of mobile website redirect javascript.

The JavaScript Method

The easiest method to auto redirect mobile users using a JavaScript code you can redirect your mobile visitors to your mobile site. This JS code can detect screen size and redirect your website. You add this code in the header of HTML. You can customize for Android, iPhone, iPad and other devices.

<script type="text/javascript">
if (screen.width <= 699) {
document.location = "YOUR-MOBILE-SITE.com";

For iPhones/iPods Specifically

<script type="text/javascript">
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {

The Plugin Method

If you are using WordPress or Joomla CMS. There are many readymade plugins which helps you to redirect mobile users.

There is a list of mobile redirect plugins

The PHP Method

If you make your site in php you can use this method for this PHP method to redirect mobile users. Add the following code to your website’s <head> section.

if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod'))
	header('Location: http://yoursite.com/iphone');

.htaccess URL Rewrite Redirects

You can use it. .htaccess Transfer visitors browser type MIME support referrals.

RewriteEngine On
# Check for mime types commonly accepted by mobile devices
RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^ http://m.domain.com%{REQUEST_URI} [R,L]

About The Author

Related Posts

Leave a Reply

Your email address will not be published.