nginx 一个域名区分pc和手机!
set $base /usr/share/nginx/html/newPc/dist;
set $mobile_request 0;
if ( $http_user_agent ~ "phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone" ) {
set $mobile_request 1;
set $base /usr/share/nginx/html/mobile/dist;
}
# gzip
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
location / {
root $base;
try_files $uri $uri @router;
index index.html index.htm;
if ($request_filename ~* ^.*?.(html|htm)$) {
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
}
}
location @router {
rewrite ^.*$ /index.html last;
}
本文来自博客园,作者:0x1cc4,转载请注明原文链接:https://www.cnblogs.com/0x1cc4/p/17962624
浙公网安备 33010602011771号