查看完整版本: 教你如何在 nginx 下自訂 404 Error Page 頁面


htctouch 2013-10-23 21:20

教你如何在 nginx 下自訂 404 Error Page 頁面

如果想在 nginx 底下設定跟 Apache 一樣自訂 404 Error Page...<div><span style="line-height: 20.796875px;">可以這樣做~~<br></span><div><br></div><div>加上紅色的段落~~</div><div><br></div>[quote]<br>server {<br><br><font color="Red">error_page 404&nbsp; /404.html;<br>location&nbsp; /404.html {<br>&nbsp;&nbsp;&nbsp; internal;<br>}</font><br><br>location ~ \.php$ {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fastcgi_pass&nbsp;&nbsp; 127.0.0.1:9000;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fastcgi_index&nbsp; index.php;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fastcgi_param&nbsp; SCRIPT_FILENAME&nbsp; $document_root$fastcgi_script_name;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; include&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fastcgi_params;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="Red"> fastcgi_intercept_errors on;</font><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>}<br>[/quote]<br><br>重啟 Nginx 就可以了~~<br></div><div><br>如果你想自訂 404.html 的頁面...讓每個 Error Page 都跳轉回首頁...可以將 404.html 修改成如下:<br>[quote]<br>&lt;html&gt;<br>&lt;head&gt;<br>&lt;meta http-equiv="refresh" content="0; url=./"&gt;<br>&lt;title&gt;&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;/html&gt;<br>[/quote]<br></div>
頁: [1]
查看完整版本: 教你如何在 nginx 下自訂 404 Error Page 頁面