Links: https://www.zhihu.com/question/20004700/answer/13678113
- The first step in the server-side using the user agent to determine, first match the mobile device, this step can be counted the user agent list (can be obtained through the website access log or use their own device collection), write the matching device of the regular expression (such as the Iphone/touch series of matching rules is /iphone os/i, if you want to fit the system version number, the rules will be more complex), according to the matching results to do the corresponding site version output.
Note that the smartphone in the mobile Cmwap access mode user-agent will be filtered by the gateway, so in the first step of the server side to determine the UA can then be in the browser side of the server to obtain access to the UA device using JavaScript two times to judge.
- There are three ways to match the results according to the first step:
A. Jump to a different URL and maintain the three sites separately (example: Facebook, major domestic portals)
B. Use different page template output pages for different devices (example: Deviantart, TUMBLR) on the same web site
C. Use only a set of front-end display, to the various devices to do a centralized adaptation (UI layout of the adaptive, front-end technology integrated compatibility, Example:/http/cubiq.org)
The first two ways of high back-end maintenance costs, suitable for mobile and PC-side product content patterns of different situations, the third approach for the consistency of the platform content, back-end maintenance costs are small, but the front-end technology and UI layout requirements are very high.
- See the solutions above
The front end determines whether the user request is a PC or a mobile end