Code Snippet

Home » Code Snippets » HTAccess » iPad Detection

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.

Subscribe to The Thread

  1. For CSS you can use

  2. David

    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

    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. 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

Speak, my friend

At this moment, you have an awesome opportunity* to be the person your mother always wanted you to be: kind, helpful, and smart. Do that, and we'll give you a big ol' gold star for the day (literally).

Posting tips:
  • You can use basic HTML
  • When posting code, please turn all
    < characters into &lt;
  • If the code is multi-line, use
    <pre><code></code></pre>
Thank you,
~ The Management ~