Nginx之偽404( root與alias )
阿新 • • 發佈:2020-07-20
目錄
一、現象
二、root與alias的區別
三、建議
四、寫在最後
一、現象
人類善於偽裝,機器某些時候也善於偽裝;Nginx請求看到404,第一反應就是檔案不存在;但我們去檢查的時候,它就正兒八經的躺在裡面;既然存在,那為什麼要404呢?二、root與alias
1、在Nginx的配置檔案中,可以使用root與alias指定工作目錄 root:指定專案的根目錄 alias:指定虛擬目錄 2、訪問的差別location /demo/ { root /test/; }
當瀏覽器訪問:http://127.0.0.1/demo/index.html時,對映到伺服器上的檔案為:/test/demo/index.html
location /demo/ { alias /test/; }當瀏覽器訪問:http://127.0.0.1/demo/index.html時,對映到伺服器上的檔案為:/test/index.html