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: Tom ClaytonTom loves to write on technology, e-commerce & internet marketing. Tom has been a full-time internet marketer for two decades now, earning millions of dollars while living life on his own terms. Along the way, he’s also coached thousands of other people to success.
css.php