server { listen 80; server_name test-h5.qc.vip; #http重定向到https rewrite ^(.*) https://$server_name$1 permanent; } server { listen 443 ssl; server_name test-h5.qc.vip; #root 配合try_files使用 root /opt/www; # 重定向 404 403 error_page 404 403 = https://www.cnblogs.com/nightOfStreet/; # app -> 活动页 # 如果try_files前面2个变量都没找到,会直接重定向第三个变量到root + /h5/index.html location ^~ /app { alias /opt/www/h5; try_files $uri $uri/ /h5/index.html; } # mall -> 商场 # alias 会移除匹配字符,将匹配到的路径加在alias路径后 https://test-h5.qc.vip/mall/pages/index ->/opt/www/mall + /pages/index location ^~ /mall { alias /opt/www/mall; try_files $uri $uri/ /mall/index.html; } add_header Cache-control no-store; }