2014-10-27 224 views
0

我目前正在我自己的網站上運行本地Apache服務器。
我有這應該404錯誤重定向到一個自定義的頁面的.htaccess文件
這就是:.htaccess不會重定向到404頁面

ErrorDocument 404 /404.php 

但我得到的是下面的錯誤,而不是我的自定義的404頁:

Not Found 

The requested URL /my-site/gqehgr was not found on this server. 

Additionally, a 404 Not Found error was encountered while trying to 
use an ErrorDocument to handle the request. 

Apache/2.4.9 (Win32) PHP/5.5.12 Server at localhost Port 80 

我在幾個論壇上看到,我可以使用RewriteEngine敘述,但我不瞭解它是如何工作的。
有人有線索嗎?

編輯:
行應該是:

ErrorDocument 404 /my-site/404.php 
+0

路徑是否正確的PHP文件? – showdev 2014-10-27 19:31:34

+0

是的。 404.php文件與站點根目錄的.htaccess位於同一文件夾中。 – Darmo 2014-10-27 19:37:31

回答

1

404.php無法找到。檢查你的文件。嘗試手動請求/404.php

+0

我知道,但它爲什麼找不到它?這是我的問題。 – Darmo 2014-10-27 19:35:24

+0

也許它位於'/ my-site/404.php'中,而不是'/ 404.php'中? – Heavy 2014-10-27 19:36:48

+0

你說得對。我很笨--_- – Darmo 2014-10-27 19:39:33