I am trying to create a custom 404 error for my website. I am testing this out using XAMPP on Windows.
My directory structure is as follows:
error\404page.html
index.php
.htaccess
The content of my .htaccess file is:
ErrorDocument 404 error\404page.html
This produces the following result:
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?
The site documents reside in a subfolder of the web root, if that makes any difference to how I should reference?
When I change the file to be
ErrorDocument 404 /error/404page.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:
The ErrorDocument
directive, when supplied a local URL path, expects the path to be fully qualified from the DocumentRoot
. In your case, this means that the actual path to the ErrorDocument
is
ErrorDocument 404 /JinPortfolio/error/404page.html
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.