I'm trying to set up a mobile version of a site, and I'm wondering if I can just set up a m subdomain and put the mobile site in there, or if I need to set up some kind of redirect to make phones automatically go to it.

Could you point me in the right direction for getting started on this? I'm having trouble finding good info.


3 Answers 3


Unless I missed something I do not believe this is automatic. These sites have made a special mobile versions of their site and are redirecting them there automatically through code on their servers.

If you know PHP there is a handy PHP code generator that will create the code for depending on your exact needs. This site seems to offer many more languages. I bet if you looked hard enough you could find a set of Apache rules to do this, too. It looks like the gist of i is to search the user agent and look for signs of the mobile phone manufacturer. So the key is to make sure this list is kept up to date.


You will definitely have to build your own redirect. It really depends on you language as to how to do it.

Also, this was asked on SO a while back, here. Check out WURLF as the SO answer suggests.

When you make the redirect you will want to make sure to use a 302 Redirect.

  • +1, Didn't know about WURLF. Gonna have to bookmark it for future reference.
    – John Conde
    Aug 18, 2010 at 17:06
  • Cool, thanks I didn't know about detectmobilebrowser.com so +1 for that one my friend! Aug 18, 2010 at 17:09

detectmobilebrowser.com redirection is based solely on the UserAgent string which can easily be modified using an add-on on Firefox, or any other method. Also, some mobile operator will change the UA string so it can make UA redirect more unstable. You can find many services working like this one.

wurlf is using some feature detection in addition to the UserAgent. Additionally, you can get some useful info about the device like screen size. This will help you render a version of your website that is best for your visitor.

So if you want to stick with free device recognition, I'd go with wurlf.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.