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; }