views:

16

answers:

1

How can I (or would you) redirect visitors visiting your web pages when they are viewing your site from a mobile phone ?

I want to set up a site with the (standard?) m. prefix.

Idially I would my visitors to be redirected to these pages when they visit my site using a mobile phone ?

I am using Windows IIS6 and IIS7.

+1  A: 

You could check the HTTP_USER_AGENT string sent in the request header. This is unique for each version of each browser. For instance you could check for the presence of 'iPhone' in the HTTP_USER_AGENT to identify iPhone users. You would need to identify all mobile phone browsers.

Or you could check the dimensions of the users viewport. If smaller than a certain size then direct to the 'mobile' phone version?

Just a thought... with mobile phone browsers getting ever more powerful is there always a need to go to a mobile phone version of the site? For instance the iPhone 4 has a massive 960x640 resolution! But I guess it is still a small form factor and users probably interact with it differently.

w3d
@w3d: Yes you do need to check for certain mobile phones (you could drop a menu from screen f.i.) or restrict the view of only 10 items of a catalogue on screen in stead of 50. I could think of all sorts of reasons. Anyway: it should be done at IIS level, I don't want my pages checking and redirecting this. And if at IIS level, how do you check the dimensions there ?
Edelcom
@Edelcom Using Apache, .htaccess and mod_rewrite you can redirect based on %{HTTP_USER_AGENT}. In fact I have just come across the [Apache Mobile Filter](http://www.idelfuschini.it/apache-mobile-filter-v2x.html)? However, I'm not so sure with IIS I'm afraid. To redirect based on screen/viewport size then I would have thought you'd need to do some page-level scripting with either web server?
w3d