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. User Avatar
    FJ
    Permalink to comment#

    For CSS you can use

  2. User Avatar
    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. User Avatar
    loftninja
    Permalink to comment#

    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. User Avatar
    Parker
    Permalink to comment#

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

    P.S :
    Flash sucks balls.

  5. User Avatar
    loftninja

    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. User Avatar
    Alex Glover

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

  7. User Avatar
    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. User Avatar
    Justin Givens
    Permalink to comment#

    Here is the Android User Agent

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

  9. User Avatar
    adam
    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. User Avatar
    Warren Laidler
    Permalink to comment#

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

  11. User Avatar
    Robin Thebs
    Permalink to comment#

    Sweet and thnx to Justin for the android detection tecnique too

  12. User Avatar
    Robin Thebs
    Permalink to comment#

    Sweet and thnx to Justin for the android detection technique too

  13. User Avatar
    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]

Posting Code

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.

Submit a Comment

icon-closeicon-emailicon-linkicon-menuicon-searchicon-tag