Redirect for Mobile Users

I have seen that many companies have a mobile version of their website. Often it is m.mysite.com instead of www.mysite.com

When you visit their site, it redirects you to the mobile site when you are on your smartphone.

How is this accomplished?
GenesisTechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

William FulksSystems Analyst & WebmasterCommented:
InMotion Hosting has a brief tutorial on the subject here - http://www.inmotionhosting.com/support/website/redirects/mobile-redirect

However, as an alternative you may consider looking into creating a responsive website where Div's collapse and rearrange based on browser width. It's a little more complicated to build BUT it keeps you from having to maintain two different sites.
0
David Johnson, CD, MVPOwnerCommented:
your browser shows a lot of information via the user agent and items that can be queried via javascript like your screen dimensions. if the browser is a 'mobile' browser or the screen dimensions are smaller than a specified size then the site is redirected to the mobile version.
0
GenesisTechAuthor Commented:
David,

Do you have any sample ASP code showing how to use the user agent?
0
David Johnson, CD, MVPOwnerCommented:
ub is_mobile()
  Dim Regex, match
  Set Regex = New RegExp
     With Regex
        .Pattern = "(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|windows ce|pda|mobile|mini|palm|ipad)"
        .IgnoreCase = True
        .Global = True
      End With
   match = Regex.test(Request.ServerVariables("HTTP_USER_AGENT"))
   If match
      return True
   Else
      return False
   End If
End Sub

Open in new window

https://mobiforge.com/design-development/lightweight-device-detection-asp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GenesisTechAuthor Commented:
Thank you David!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Responsive Web

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.