2017-10-04 75 views
0

我的nginx文件如下。我試圖將所有404請求重定向到我的index.html。在客戶端,我有自定義客戶端路由邏輯來處理URL。nginx自定義404錯誤頁面不能正常工作

但是默認的nginx 404頁面仍然被調用。 (例如:轉到http://branches-app.com/Languages/Spanish)。

http { 
    ....... 
    server { 
      listen [::]; 
      listen 0.0.0.0; 
      proxy_intercept_errors on; 
      error_page 404 /index.html; 
      location = /index.html { 
        root /var/www/html; 
        allow all; 
      } 

    } 

} 

我在做什麼錯?

+1

你當前的配置在''/ var/www/html/index.html/index.html'查找該文件嘗試:'root/var/www/html;' –

+0

@RichardSmith,改變了它。還是行不通。 – johnsimer

回答

0

想通了!我有一個include指令,其中包含另一個conf文件,它有一個服務器指令,覆蓋了我在上面發佈的文件中的指令。