Apache custom 404 page not loading
Your current configuration expects the custom error page to be found on http://www.example.com/var/www/html/mant.html
.
The path to the ErrorDocument is an URL path, either relative to your DocumentRoot:
<VirtualHost *:80>
DocumentRoot /var/www/html/
ErrorDocument 404 /mant.html
</VirtualHost>
or an absolute URL such as:
<VirtualHost *:80>
DocumentRoot /var/www/html/
ErrorDocument 404 http://www.example.com/mant.html
</VirtualHost>
it is not a path on your file-system.
Edit: Based on your comment
The problem is the document root folder is deleted once the build starts so at that time someone try to access it should return the 404 error page.
Then store your error pages outside of the DocumentRoot where they won't be deleted:
Alias /errors/ /var/www/errors/
ErrorDocument 404 /errors/404.html`
Related videos on Youtube
![shellakkshellu](https://i.stack.imgur.com/MVxXV.jpg?s=256&g=1)
Comments
-
shellakkshellu almost 2 years
I am trying to set up a custom error page for
404
error on my apache server.Here is what I am included in the
Virtualhost
<VirtualHost *:80> ErrorDocument 404 /var/www/html/mant.html </VirtualHost>
But this page is not showing instead its redirect to default 404 page
Note:
I've restarted the apache with
sudo service apache2 restart
I am able to access the error page with the following url
<ip>/mant.html
-
shellakkshellu almost 6 years@HBrujin the problem is the document root folder is deleted once the build starts so at that time someone tries to access it should return the 404 error page.