我目前正在我自己的网站上运行本地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
路径是否正确的PHP文件? – showdev 2014-10-27 19:31:34
是的。 404.php文件与站点根目录的.htaccess位于同一文件夹中。 – Darmo 2014-10-27 19:37:31