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.
if ( (navigator.userAgent.indexOf(‘Android’) != -1) ) {
document.location = “https://www.yourwebsite.com/android-version.html”;
}
shouldn’t be missing 😉
Thanks 🙂
appreciated the comment. I’ll add it to the list cheers
If you want full coverage of all devices this collection of scripts might help:
https://detectmobilebrowsers.com/