Nginx自定義404頁面(Linux環境下配置)

2021-07-10 09:21:56 字數 671 閱讀 8111

首先開啟nginx.conf檔案,在fastcgi_temp_file_write_size 128k;下面新增

fastcgi_intercept_errors on;注意,包括;

然後在需要定義的站點的裡面(筆者的檔案是/alidata/server/nginx/conf/vhosts目錄下的lbinin.conf檔案)

root /alidata/www/lbinin;下新增error_page 404 = /404.html;

/404.html表示把自定義的404.html放在伺服器根目錄下)

同理,若要新增403頁面,**為:error_page 403 = /403.html;

然後儲存,重啟nginx。

/etc/init.d/nginx start/stop/restart/reload

比如啟動 nginx:

/etc/init.d/nginx start

Nginx自定義404頁面

usr local nginx html 404.html我們需要來配置一下 nginx.conf 檔案中關於 404 錯誤頁面的跳轉 1 我們在http全域性配置中加入如下配置 proxy intercept errors on 這個引數的作用是使得用nginx做 的網頁也生效,沒用nginx做 ...

nginx如何設定自定義404頁面

下面是lnmp設定nginx 404錯誤頁教程 vi usr local nginx conf nginx.conf 編輯nginx配置檔案,在http 區段新增下面 fastcgi intercept errors on 編輯 配置檔案,比如本站 vi usr local nginx conf v...

thinkphp自定義404頁面

使用emptycontroller empty方法。當我們使用thinkphp框架對外提供服務時,如果不採取特殊配置,當乙個請求沒有訪問到服務端資源,會直接返回404,並且由於thinkphp的特性,會返回乙個帶有thinkphp個性色彩的404頁面。這樣的頁面至少有兩點不太好 1 暴露了服務端的技...