自404 Apache的错误问题错误、问题、Apache

2023-09-02 00:21:34 作者:放肆嘚寂寞只因爲你

我想为我的网站创建一个自定义404错误。我使用的XAMPP在Windows上测试了这一点。

I am trying to create a custom 404 error for my website. I am testing this out using XAMPP on Windows.

我的目录结构如下:

error404page.html
index.php
.htaccess

我的.htaccess文件的内容是:

The content of my .htaccess file is:

ErrorDocument 404 error404page.html

这将产生以下结果:

然而,这是行不通的 - 它是什么做的方式是斜线或如何,我应该引用错误文件

However this is not working - is it something to do with the way the slashes are or how I should be referencing the error document?

网站的网站文件驻留在一个在Web根目录的子文件夹,如果说有什么区别,我应该如何参考?

site site documents reside in a in a sub folder of the web root if that makes any difference to how I should reference?

感谢您先进的。

当我更改该文件是

ErrorDocument 404 /error/404page.html

我收到这不是什么是HTML文件里面我已经把下面的错误消息 - 但它是不同的东西如上面的:

I receive the following error message which isn't what is inside the html file I have linked - but it is different to what is listed above:

推荐答案

的ErrorDocument 指令,当提供本地URL路径,预计将在 的DocumentRoot 。在你的情况,这意味着实际路径的ErrorDocument

ErrorDocument 404 /JinPortfolio/error/404page.html

当你在你的第二次尝试纠正它,原因你看到的页面,而不是因为的http://localhost/error/404page.html 不存在,因此对那里正在查找错误处理文件404错误的位。

When you corrected it in your second try, the reason you see that page instead is because http://localhost/error/404page.html doesn't exist, hence the bit about there being a 404 error in locating the error handling document.

 
精彩推荐
图片推荐