Knowledgebase

Back to Troubleshooting

How To Redirect Users To A Mobile Web Page


The standard redirection for users connecting from a smartphone or mobile device is to utilize m.yourdomain.com. For users coming from these mobile devices to see your mobile website, they will need to be redirected appropriately.

Many mobile devices do not have indicators that they are mobile - so the redirection process can be tricky. The browser on every device will indicate its "user-agent" which tells the server the browser name, version, and other general OS information. Based on this handshake, you should be able to determine if they are a mobile visitor and redirect them accordingly.

Here are a couple of options for redirecting your mobile users:

Plugins

If you are running a CMS (Content Management System) like WordPress or Drupal, they often have plugins available that help with handling mobile users. Search online or through the marketplace of your CMS to find out more here.

Javascript Redirection

Mobile devices usually have small screen settings, and you can redirect visitors to your mobile site if they have a screen width of less than or equal to 800 pixels. You can use the following code to do this:

<script type="text/javascript">
	<!--
	if (screen. width <= 800) {
		window.location = "http://m.domain.com";
	}
	//-->
</script>

While testing this on a SAMSUNG smartphone, the screen resolution varied based on how the phone was held, since the screen automatically flips. To get the best results, you may have to test with various smartphones until you get it at the right setting for your site.

Please keep in mind however that if the user does not have javascript enabled, this will not work.

.htaccess redirects

These are the most common redirect formats. You can use a .htaccess redirect to transfer users based on the MIME types that their browser accepts. For example, if the user's browser accepts things like WML (Wireless Markup Language), then it's probably a mobile device and can be safely redirected.

The code below should be placed in your .htaccess file:

RewriteEngine On
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


Related Articles

My Emails I Send Are Being Received In The Junk Folder
Can I Backup My Outlook Mail Data
How To Change An Email Account Password
How To Change An Email Forwarder Into Full Email Account
How To Create An Email Account

Can’t Find what you need?

No worries, Our experts are here to help.