Search code examples
iis-7http-redirectwebiis-6mobile-phones

How can I redirect my wb site visitors to an m.mydomain.com version when started from a mobile phone?


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.


Solution

  • 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.