Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

My Question is that when user enter the website: http://www.example.com then they will just go to automatically to http://www.example.mobi how can i do this .. is their any technique behind that.

Can i do this via cPanel etc?. Tutorial links are welcomed.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

To redirect only mobile traffic to a mobile domain there are a few options:-

Simple

Based on screen resolution (my favorite as it's fairly future proof)

<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "www.mobileurl.com";
}
//-->
</script>

More granular control

http://detectmobilebrowsers.mobi/ offers more complete control with a free script which handles redirection to a single place, or multiple places based on device (don't be fooled by all the buy buttons!)

require_once('[mobile_device_detect.php][4]');
mobile_device_detect(
  'http://iphone-url.com',
  'http://ipad-url.com',
  'http://android-url.com',
  'http://opera-mini-url.com',
  'http://blackberry-url.com',
  'http://palm-os-url.com',
  'http://mobile-url.com',
  'http://mobile-browsers-url.com',
  'http://desktop-url.com');

Allowing traffic from different devices to be sent to different urls.

Extremely granular control

Other than that there are device description databases like WURFL which offer even more in depth control by providing a database that can be queried using device header information and traffic redirected accordingly...

share|improve this answer
    
is this helpful technique and i don't understood full, is this redirect the main domain. means if some one open in web-browser on the laptop/desktop computer then its not show .mobi domain but if some one enter to the mobile devices they have to redirect to the .mobi domain .. i just want that ... –  Appz Venture Mar 13 '12 at 17:09
    
@AppzVenture Oh, I see, you want to redirect ONLY mobile traffic to a mobile domain? Different kettle of fish, I'll update my answer –  toomanyairmiles Mar 13 '12 at 17:27
    
@AppzVenture updated with a few solutions for you... –  toomanyairmiles Mar 13 '12 at 17:48
    
Thanks thats really helpfull its solve lot of my time and investment. Thanks too much –  Appz Venture Mar 23 '12 at 13:16
    
@AppzVenture No worries. –  toomanyairmiles Mar 23 '12 at 13:19

The first method (screen.width<=799) is not reliable. On my Android, I get a screen width of 540 when the phone is being held upright (portrait view), but if I turn it on its side (landscape view), I get width=960. Better (maybe still not fully reliable) might be to bounce to mobile if either dimension is small:

if ((screen.width <= 699) || (screen.height <= 699)) {}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.