• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

0x1cc4

Youth means limitless possibilities. 年轻就是无限的可能。
  • 订阅
  • 管理

公告

View Post

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

posted on 2024-01-13 17:17  0x1cc4  阅读(185)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3