2
votes

i am trying to show an custom error message when a page is not found and on my .htaccess i added a line like this:

ErrorDocument 404 error/404.html

but this just shows me 404.html on the screen instead rendering the 404.html page and if i write it like this

ErrorDocument 404 /error/404.html

than it gives me an error

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

Is there another way to do this to show the actual error html page ? Thank you, Daniel!

1
Explain: "shows me 404.html on the screen instead rendering the 404.html page" - Ravi K Thapliyal
What is your document root? The path should be relative to your document root. URLs can begin with a slash (/) for local web-paths (relative to the DocumentRoot), or be a full URL which the client can resolve. httpd.apache.org/docs/2.2/mod/core.html#errordocument - showdev
on localhost on the folder "site" i have .htaccess and a subfolder "error" with the file "404.html" inside when i request a page that is not in the folder "site", errordocument works but instead showing the content of the page "404.html", it just shows the browser write with the text 404.html on it.. actually the text is "error/404.html" - Pacuraru Daniel
if i upload the content on the web, it works starting with a slash (/) but on localhost it doesnt work - Pacuraru Daniel
Shouldn't it be: ErrorDocument 404 /site/error/404.html? - anubhava

1 Answers

2
votes

As per your description it appears that your error folder is inside DOCUMENT_ROOT/site folder. In that case following full path ErrorDocument directive should work for you:

ErrorDocument 404 /site/error/404.html