douyao1856 2015-12-20 13:35
浏览 50

如何将移动用户和PC用户重定向到另一个URL,但是在同一个网页中

How do I direct phone users to m.test.com //for mobile*

and PC users to test.com // pc user in php? Or should I do it in CSS?

  • 写回答

2条回答 默认 最新

  • douli0531 2015-12-20 13:41
    关注

    Basically, what you want is a browser switch: You act on the information, which browser is requesting and from which OS. You can do this either on the server (PHP) or on the client (JS):

    • Server sided: Use either $_SERVER['HTTP_USER_AGENT'] or get_browser(), then send a redirect via header() as needed
    • Client sided: User navigator.userAgent and friends to decide, then set location.href to do the redirect.
    评论

报告相同问题?