本篇內容介紹了“nginx解決VUE重定向刷新指向首頁的方法”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
當用戶請求 http://localhost/example 時,這里的 $uri 就是 /example。 try_files 會到硬盤里嘗試找這個文件。如果存在名為 /$root/example(其中 $root 是項目代碼安裝目錄)的文件,就直接把這個文件的內容發送給用戶。 顯然,目錄中沒有叫 example 的文件。然后就看 $uri/,增加了一個 /,也就是看有沒有名為 /$root/example/ 的目錄。 又找不到,就會 fall back 到 try_files 的最后一個選項 /index.php,發起一個內部 “子請求”,也就是相當于 nginx 發起一個 HTTP 請求到 http://localhost/index.php。
` server { listen 808; #server_name rc.huanwei.tidecloud.com;
root /var/www/html; index login.html index.htm; #rewrite /index.html /login permanent; location / { try_files $uri $uri/ [@router](https://my.oschina.net/u/2258684); index index.html; } location [@router](https://my.oschina.net/u/2258684) { rewrite ^.*$ /index.html last; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|html)$ { root /var/www/html/rc.huanwei.tidecloud.com; } location /api-customer { proxy_pass http://192.168.0.110:13200; }
}
“nginx解決VUE重定向刷新指向首頁的方法”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。