Since the Ipad doesn't work nicely with issuu I'm trying to set up a system where if users would acces one of my blog post from an ipad device they get redirected to the a pdf file which is on my server.

For this I'm guessing I would have to include some kind of HTML code at the beginning of each post. However I'm not familiar with HTML. Is it possible to redirect visitors from my wordpress blog based on their browser (safari) or device (iPad)?

It tried this but it didn't work:

<!--[if safari]> <a href="http://blog.united-academics.org/wp-content/uploads/2011/04/Food-hunger.pdf" target="_blank">HTML Help</a><![endif]-->

Hope you guys can help!

3 Answers 3


A quick Google shows up with this

There's 2 ways you can do this:

  1. Detect the user agent with JavaScript and redirect
  2. Detect the user agent server-side and redirect

With JavaScript you'd modify the code on the page linked above, with PHP you'd compare $_SERVER['HTTP_USER_AGENT'] to whatever the user agent of iPads contain.


The ipad has a user-agent string;

Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us)
AppleWebKit/531.21.10 (KHTML, like Gecko) 
Version/4.0.4 Mobile/7B334b Safari/531.21.10

You can detect and re-direct the user-agent in your header or at the server level.(these examples are for iPad only not iPhone or safari).


$isiPad = strpos( $_SERVER[ 'HTTP_USER_AGENT' ],'iPad' ) !== false;


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


var isiPad = navigator.userAgent.match(/iPad/i) != null;

Media Query:

media="only screen and (max-device-width: 1024px)"

You can use the plugin mobble and this plugin will give you access to the function is_ipad()


if(is_ipad()) {
    // do redirect

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.