User Agent Detection For Apple Devices

What’s A User-Agent

Sometimes it’s necessary for a web site to understand how it is being viewed, so most user agents identify themselves by sending a User Agent String to the web site. (A string is a series of characters, usually letters and numbers.) If you want to view your user-agent head here.

Redirecting Using Javascript

Detecting and redirecting for an iPad.

[code type=javascript]

[/code]

Detecting and redirecting for an iPhone.

[code type=javascript]

[/code]

Detecting and redirecting for an iPod.

[code type=javascript]

[/code]

Detection For Android

Thanks to Dylan

[code type=html]
if ( (navigator.userAgent.indexOf(‘Android’) != -1) ) {
document.location = “https://www.yourwebsite.com/android-version.html”;
}
[/code]

Redirecting Using .htaccess

Detecting and redirecting for an iPad.

[code type=html]
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} iPad
RewriteCond %{REQUEST_URI} !^/my-iPad-site/
RewriteRule .* /my-iPad-site/ [R]
[/code]

Detecting and redirecting for an iPhone.

[code type=html]
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} iPhone
RewriteCond %{REQUEST_URI} !^/my-iPhone-site/
RewriteRule .* /my-iPhone-site/ [R]
[/code]

Detecting and redirecting for an iPod.

[code type=html]
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} iPod
RewriteCond %{REQUEST_URI} !^/my-iPod-site/
RewriteRule .* /my-iPod-site/ [R]
[/code]

Detection For Android

Thanks to Dylan

[code type=html]
if ( (navigator.userAgent.indexOf(‘Android’) != -1) ) {
document.location = “https://www.yourwebsite.com/android-version.html”;
}
[/code]

Conclusion

Thanks for taking part in this code snippet, if you have any questions feel free to post them up on our Facebook Fan Page Or Tweet them via twitter @photoshop_plus.

Author: Sam ZamanSam loves to write on technology & related stuff. Ecommerce, mobile and internet marketing equally drive her interest. Likes gardening and experimenting with new recipes. An avid reader and absolutely mad @bout donuts :)

3 thoughts on “User Agent Detection For Apple Devices”

  1. if ( (navigator.userAgent.indexOf(‘Android’) != -1) ) {
    document.location = “https://www.yourwebsite.com/android-version.html”;
    }
    shouldn’t be missing 😉

    Reply

Leave a Comment