Note to self: A simple way to accomplish mobile site redirection using mod_rewrite

| 2 Comments

In preparation for the launch of The Tyee’s mobile-friendly site (not to be confused with The Tyee’s HTML5 “app” for mobile devices), I did some research on approaches to mobile site redirection. The key considerations were straightforward:

  • The redirection should happen quickly
  • The redirection should be as simple as possible
  • There should be a way for the user to enable/disable the redirection

The solution I ended up with, based largely on this blog post, is as basic as I could get it. It relies on cookies for persistence of the user’s choice to view the mobile site, or the full site, but it also works properly without cookies when the user is simply switching between the mobile view and the full site view.

There you go. :) Your mileage may vary.

Remaining questions for me are:

  • How long to persist the mobile site vs. full site cookie?
  • How to let users know that they can change back to the mobile site from the full site? (Lots of options here.)

Have suggestion or improvements? Drop me a note or a comment.

Comments

2 Comments

> How to let users know that they can change back to the mobile site from the full site? (Lots of options here.)

If you're after an Apache implementation you could do a BrowserMatch to set an environment variable
http://httpd.apache.org/docs/2.2/mod/mod_setenvif.html#browsermatch

Then use an environment variable to conditionally include a big link to the mobile version
http://httpd.apache.org/docs/current/mod/mod_include.html#substitution

Leave a comment

TrackBack URL: http://www.phillipadsmith.com/trackback/2754