Looking for help on deciding how to redirect users to a mobile optimized version of my site (m.mysite.com).

Looking at two methods:

  1. Server configuration (.htaccess or even varnish)
  2. Webapp (php)

The problem I see with #1 is with the "view full site" link on the mobile site. If a user clicks that link and they go to mysite.com won't the server just redirect them back to m.mysite.com?

For #2 I could create a cookie that is checked in addition to the user agent.

Any suggestions/comments? Is there a better way to "remember" if the user clicked "visit full site"?

  • 3
    You can check for cookies using mod_rewrite: look at RewriteCond %{HTTP_COOKIE} ... and build your logic around. Each approach is possible. #2 is easier but required PHP to get involved which is more "expensive" in terms of CPU/resources than mod_rewrite (although it should be absolutely fine on any modern hardware unless it is under heavy load and limited in resources).
    – LazyOne
    Commented Jul 13, 2011 at 11:27
  • I'm facing the exact same issue. I'm going with route number 2, because I want to people to be able to click the visit full site link on their mobile device. Did you figure out how to manage the cookie? Jim
    – user9345
    Commented Aug 2, 2011 at 18:49

2 Answers 2


I'd suggest that you use option #1 and set a cookie once they've been redirected. This will be effective in not just the current session of the user; but also future sessions.


The only alternative to using a cookie is having your portal (index) redirect to m.mywebsite.com with the implicit understanding that m.mywebsite.com will never link to the plain pages at mywebsite.com.

Also take a look here: http://csswizardry.com/2010/01/iphone-css-tips-for-building-iphone-websites/

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.