Here is the small trick with which you can detect the iPad using htaccess file and make the redirection accordingly.
This will be very useful when you are about to create a separate page for iPad users and want then to redirect.
Have a look at below code block which detects the iPad using htaccess file and redirecting to separate page for iPad.
[cc lang=”apache”]
RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://your-domain.com/ipad.html [R=301]
[/cc]
You can see that this code uses one of the available server variable which is User Agent and checking for the ipad using regular expression. If that condition satisfies then it will perform the redirection step just below it.
If you want to detect multiple devices you can use this:
RewriteCond %{HTTP_USER_AGENT} ^.*(iphone|android).*$ [NC]
RewriteRule ^(.*)$ http://your-domain.com/ipad.html [R=301]
Oh boy, bad practice. You CSS to deliver the appropriate content to your devices.
Chris, using .htaccess to detect a device is not bad practice. Now if you don’t give an option to view the full site, then you’re using bad practice.
Just using CSS and not allowing someone to view the full site would be ‘bad practice’.
Here’s a method via .htaccess that does user agent detection and allows the user to view the full version of the site if they wish.
http://mobiledrupal.com/simple-apache-configuration-file-mobile-device-detection
Agreed… :)
How do you forward to different sites depending on different platforms?
Here platform refers to OS?
Thanks for the tips, will the same trick works for the new ipad?
yes it will work…