nginx設(shè)置404錯誤頁麵方法
1.創建(jiàn)自己的404.html頁麵
2.更改nginx.conf在http定義區域加入:
fastcgi_intercept_errors on;
3.更改nginx.conf或虛擬主機(jī)的(de)域名.conf在server 區域加入:
error_page 404 /404.html;
4.測試nginx.conf正確性:
/usr/local/nginx/sbin/nginx -t
如果正(zhèng)確應該顯示如下信息:
the configuration file /opt/nginx/conf/nginx.conf syntax is ok
configuration file /opt/nginx/conf/nginx.conf test is successful
5.重啟(qǐ)nginx
/usr/local/nginx/sbin/nginx -s reload
注意事項:
1.必須要添(tiān)加:fastcgi_intercept_errors on; 如果這個選項沒有設(shè)置,即使創建了404.html和配置了error_page也沒(méi)有效果。
2.不要出於省事或者提高首頁權重的目的將首頁指定為(wéi)404錯誤頁(yè)麵,也不要用其它方法跳轉到首頁。
3.自定義的404頁麵必須大於512字節,否則可能會出現IE默認的404頁麵。例如,假(jiǎ)設自定義了404.html,大小隻有11個字節(內容為:404錯誤)。
關鍵詞:nginx,404錯誤頁麵(miàn)
閱讀本文後您(nín)有什麽(me)感(gǎn)想? 已有(yǒu) 人給出評價(jià)!
- 0
- 0
- 0
- 0
- 0
- 0