I want to forward my viewers on my site to a different place if they are using an iPhone. Is there a way to do that using iWeb?

4 Answers 4



The only reasons to ever have a separate mobile site are cheapness and laziness.

The right approach is to have your visitors all get the same content; the only thing that should change how that content is styled—and doing that doesn't need a separate site, or even a special page.

If your next question is "Can iWeb do that?," the answer is that I doubt it, because iWeb just isn't meant to be a professional web development tool. If you're looking for an alternative, I recommend TextWrangler—it's both better and cheaper.


1 Yes, they're both me.

  • 1
    Thank you for your answer. But I wasn't looking for opinions on IF it should be done; but how it CAN done. -1
    – Linuxmint
    Commented Jan 1, 2011 at 3:31
  • 5
    I appreciate this doesn't answer the question, but it is worth pointing out to less experienced web developers. If you do have a separate mobile site, at least have an option to view the normal site. It is extremely frustrating when poorly designed web sites prevent access to information because the insist on using a crappy mobile version of the site when the iPhone can handle viewing the normal site just fine.
    – g .
    Commented Jan 1, 2011 at 15:06
  • @Linuxmint - No one will be able to tell you how to do it with iWeb, as iWeb just cannot do it—it's not a real Web development tool. If you don't like that answer, that's not my problem; I was simply trying to help (a mistake I won't repeat).
    – Dori
    Commented Jan 2, 2011 at 1:36
  • 1
    +1 even if it does not answer the question on the title, it is very insightful and does give the best solution for the problem.
    – cregox
    Commented Jan 2, 2011 at 23:19
  • 2
    As an iPhone user, when I make a Google search and click on a search result I expect to land on the page with the content I was looking for -- not some random "welcome iphone users" page. This will result in me going back to Google's results and selecting a different website. Commented Jan 3, 2011 at 14:44

You can use this script in the HEAD section of your index file.

<script type="text/javascript">
        var agent=navigator.userAgent.toLowerCase();
        var is_iphone = (agent.indexOf('iphone')!=-1);
        if (is_iphone) { window.location ="http://www.yourPage.com/iphone" }

and redirect your visitor to iPhone compatible page. See an example on http://www.barisoztekin.com


You can do it from the environment settings passed to a CGI or app called by the server. The HTTP_USER_AGENT field describes the client connecting to the server, and is what is often used to branch or redirect based on a particular browser.

The downside to sensing with that is it can be spoofed and/or changed in a lot of client software.

  • 2
    To contribute: there isn't going to be an easy way to do this via iWeb. You'll have to do a 'publish' of the site to a directory on your computer and manually edit the code, adding the prerequisite checking of the user agent. Then you can separately push that folder up to the FTP for your site. Commented Jan 1, 2011 at 0:43

Typically this is done server side by evaluating the User Agent that is passed with the HTTP request. I believe iWeb just publishes static pages and doesn't support dynamic content. In that case you will probably need to resort to using JavaScript so that the redirect is performed client side.

Be careful when using this approach though as it has the potential to create a poor user experience. It would be best to establish a way to allow the user to view the page if they really want to. Typically this is done with a cookie if the user selects that they want the 'normal' site rather than the 'mobile' one.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .