2017-07-02 54 views
1

我有以下問題。我有角2應用程序,它存儲在與後端相同的服務器上。我有api通過/ api路由,也有/ apidoc路由。我有以下nginx的配置可以讓歷史的API角2應用工作:Nginx配置爲404.html

location/{ 
    try_files $uri/index.html $uri.html $uri @app; 
    gzip_static on; 

    rewrite 「^/faq」 /index.html last; 
    rewrite 「^/support」 /index.html last; 
    rewrite 「^/issue/*」 /index.html last; 
    rewrite 「^/settings」 /index.html last; 
    rewrite 「^/reset」 /index.html last; 
    rewrite 「^/confirm」 /index.html last; 
    rewrite 「^/terms」 /index.html last; 
} 

我需要的所有航線(不含/ API/*,/ apidoc及以上配置提及)重定向到404.html。我需要在config中寫入以實現此目的?

回答

1

嘗試增加您的位置下面這段代碼:

location ~ ^(?!\/(404|index|api|apidoc|faq|support|issue|settings|reset|confirm|terms)\b).* { 
    error_page 404 /404.html; 
} 

它可能工作