Grow your CSS skills. Land your dream job.

Last updated on:

iPad Detection

Of course, the iPad is a pretty large screen and a fully capable browser, so most websites don't need to have iPad specific versions of them. But if you need to, you can detect for it with .htaccess

RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://ipad.yourdomain.com [R=301]

This will redirect iPad users to a URL you specify. This is probably the best way to do it (assuming you are running an Apache server), but if you aren't, there are PHP and JavaScript methods here.

Comments

  1. FJ
    Permalink to comment#

    For CSS you can use

  2. David
    Permalink to comment#

    Actually, I’m under the assumption that this snippet could also be used to make sure an capable iPad sees the full and normal version of your site … As the poster mentions, the iPad has full size screen and capable browser … yet I’ve experienced while using Safari on the iPad, many sites currently detect the mobile version of Safari and dump me into the mobile versions of their site, then I continually have to hunt for a way to get to the standard version on many pages, this is annoying (Twitter for instance hides the link to the standard version of their pages, all the way at the bottom of their footer)

  3. i’ve written a jquery slider version of my site at electricarms.com/Slider.html gonna try to implement this…thanks for the tips

  4. Parker
    Permalink to comment#

    wow your site (electricarms.com/Slider.html) needs way more blue in it.

    P.S :
    Flash sucks balls.

  5. thanks parker…i’ve done everything but the flash part on the site so i’m glad its not my work that sucks balls-you must have missed the point of the site because you are working with Windows 95

    PS:
    sarcasm is far more awesome than flash, but it sucks balls too

  6. How would just change the css file instead of the whole site.

  7. Dave

    Is it possible to use the .htaccess rewriterule to only redirect one page within a site? For example, if one page has a flash object, can I redirect requests for that one page to a static version just for iPads?

  8. Here is the Android User Agent

    RewriteCond %{HTTP_USER_AGENT} ^.*Android.*$

  9. Permalink to comment#

    I’m up to my elbows in a behemoth 600 page raw code HTML/JS site that wants to be optimized it for ipad. It was optimized by the last guy for iphone and I can see it in the js…the two chunks of code for browsers and iphone are the same. What do I add to the file to optimize for ipad? Or where can I look? Everything I’m finding is for apps… -am

  10. I dont use PHP but this ASP solution is working perfectly for me.

  11. Sweet and thnx to Justin for the android detection tecnique too

  12. Sweet and thnx to Justin for the android detection technique too

  13. jpixley
    Permalink to comment#

    and to any noobs like me, putting ‘RewriteEngine On’ seemed to be the thing that finally made this work for me, i.e…

    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} ^.iPad.$
    RewriteRule ^(.*)$ http://subdomain.yoursite.com [R=301]

Leave a Comment

Current day month ye@r *

*May or may not contain any actual "CSS" or "Tricks".