REDIRECT AN IPHONE USER TO ANOTHER WEBSITE

Posted by: Søren in Technology

A rising interest in mobile browsing on iPhones has increased the demand for mobile optimized websites. From a business point of view there are many reasons to have an eye on this trend. The mobile generation consumer segment is rapidly rising in Europe. This trend is mainly driven by smartphones and especially Apple's iPhone (Source: Børsen). To meet this development a lot of companys need to get themselves an iPhone/mobile website - a least to make a buzz out of themselves.

Having developed my own iPhone optimized website I have been forced to take some controversial decisions. Can you force a internet browser to redirect him/her to another website automatically? Well. Depends on many things. After all I decided to give the user the opportunity to make the decision themselves - either to watch an website in an iPhone optimized version or in a full version. If you do not want to give the user this option, but just want to redirect an iPhone user directly. Well. Take a look on the scripts below:

The nerdy stuff:

A lot of websites - e.g. cover.dk has an iPhone optimized website and when the consumer point his/her browser to cover.dk they are being redirect to Cover's iPhone optimized website automatically. Smart!.

To do this you just need a simpe javascript or a simple PHP code on your website. Inset one of these codes on your Index file and your visitors will be redirected to your iPhone website automatically:

JS:



Or PHP

//setting the variables
$ipod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iphone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");

//detecting device
if ($ipod == true || $iphone == true){
header( 'Location: http://site-1/' ) ;
} else {
header( 'Location: http://site-2/' ) ;
}
?> Overall I am quite happy with the result.

Check it out for yourself on cover.dk or www.vw.com.

Comments (6)Add Comment
...
written by Søren Ørnholt Jørgensen , August 07, 2009
Mobile branding is growing! http://bit.ly/7tHRG
...
written by Søren Ørnholt Jørgensen , August 22, 2009
More iPhone codes here: http://bit.ly/3efU3Z
...
written by Jacob , December 28, 2009
Thanks very much :)
...
written by Søren Ørnholt Jørgensen , December 29, 2009
@Jacob: You are welcome!
...
written by Søren Ø , June 27, 2010
Redirect an iPhone user with with .htaccess:

http://www.htaccesstools.com/articles/detect-and-redirect-iphone/

Cheers
...
written by Alberto Rojas , July 03, 2010
Is this code SEO?

Thanx!

Write comment
smaller | bigger

security code
Write the displayed characters


busy