How can I redirect my website for mobile?

I know I have to create a new website for mobile, but how do I make it so that the mobile automatically redirects to my mobile website.

Your phone will NOT just recognize if there is a mobile version available.

If your website is built correctly, you only need a stylesheet. Then when you are adding the <link /> tag, add the media type as handheld like this media="handheld"

So when the webpage is accessed by a mobile device, the browser will know to load the handheld css file.

The other option is to add some kind of check to see if the browser is on a mobile phone. For example in PHP on an HTC phone

<?php
if($_SERVER['HTTP_USER_AGENT'] == ‘HTC_Pro_T7272 Opera/9.50′) {
header(‘http://domain.com/mobileversion");
exit();
}
else
{
echo ‘Show regular site for PCs.’;
}
?>

Also be sure to check for all Mobile User Agent Strings.

2 Comments

  • Daz Owen
    July 27, 2011 - 10:50 am | Permalink

    You phone will recognise if their is a mobile version of the site and it will automatically redirect you to that page.
    References :
    Experienced User.

  • candyeclipseonair
    July 27, 2011 - 11:27 am | Permalink

    Your phone will NOT just recognize if there is a mobile version available.

    If your website is built correctly, you only need a stylesheet. Then when you are adding the <link /> tag, add the media type as handheld like this media="handheld"

    So when the webpage is accessed by a mobile device, the browser will know to load the handheld css file.

    The other option is to add some kind of check to see if the browser is on a mobile phone. For example in PHP on an HTC phone

    <?php
    if($_SERVER['HTTP_USER_AGENT'] == ‘HTC_Pro_T7272 Opera/9.50′) {
    header(‘http://domain.com/mobileversion");
    exit();
    }
    else
    {
    echo ‘Show regular site for PCs.’;
    }
    ?>

    Also be sure to check for all Mobile User Agent Strings.
    References :
    http://www.w3.org/TR/CSS2/media.html
    http://www.zytrax.com/tech/web/mobile_ids.html
    http://cliftonhatfield.com

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>