项目目录:
配置:
#user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;sendfile on;
#keepalive_timeout 0;
keepalive_timeout 65;#gzip on;
server {
listen 8093;
server_name localhost;
proxy_request_buffering off;
proxy_buffering off;location / {
if ($http_user_agent ~* "(mobile|nokia|iphone|ipad|android)") {
root html/cloud-yd;
break;
}
root html/cloud-pc;
index index.html index.htm;
}error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
核心代码:
if ($http_user_agent ~* "(mobile|nokia|iphone|ipad|android)") {
root html/cloud-yd;
break;
}
根据需求不一样,有时ipad不是进入移动端,所以可能需要修改。