使用 .htaccess 自訂 “404 找不到網頁” 的頁面
一般我們租用的虛擬主機無法讓我們修改 httpd.conf,所以只能透過使用 .htaccess 來自訂 “404 找不到網頁” 的頁面。
首先確認你的網頁伺服器是 Apache,沒問題的話,編輯網頁根目錄下的 “.htaccess”,加入:
<IfModule mod_rewrite.c> RewriteEngine On ErrorDocument 404 /error404.html </IfModule>
如此即可將 404 的頁面導到 “/error404.html” 這個網頁來執行。接著將你自已設計的 error404.html 直接放在網頁根目錄,這樣就完成了。
另外,這裡有一些很有創意的 404 Error Page。
相關的網頁錯誤代碼主要有:
- 400: Bad request
- 401: Authorization required
- 403: Forbidden
- 404: Worng page
- 500: Internal server error
參考網址
- 404 Error Pages
- Wanted: Your 404 Error Pages
- Area 404
- HTTP 回應的代碼含義
- 改變網址而不會出現「404 找不到網頁」:301 Redirect 與 .htaccess
您可能會對以下這些文章感興趣
2008
23
6月
- Posted by citypig at 07:24 pm (11,248 views)
- Permalink for this entry
- Filed under: 404, apache, webdesign
- RSS comments feed of this entry
- TrackBack URI











2009-11-25 10:37
[...] 使用 .htaccess 自訂 “404 找不到網頁” 的頁面 [...]
Browser: