try_files踩坑記錄


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM