Hello, I would like to ask about the best way to implement a custom 404 page. I had already found a small bit of help within the community about how to do this, but all seemed irrelevant. My issue is that I do not have a .htaccess file, and that I could build one, but even then, I do not know where to put it, and it is not the best solution anyhow. I read that I should instead use the httpd.conf file, but I do not have that file in my server either. What I have that I believe to be related are a localized-error-pages.con file, and a apache2.conf file. Should I be editing either one of these to include the ‘ErrorDocument 404’ line? Or is there a better way?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This question was answered by @JonsJava:
Easiest way is with an .htaccess or a modification of your vhost configuration for apache. Something like this
You can either edit /etc/apache2/sites-enabled/000-default (Debian/Ubuntu) or /etc/httpd/conf/httpd.conf (Fedora/CentOS), and within the < VirtualHost > block, add this:
ErrorDocument 404 /notfound.htmlchanging /notfound.html to the location of the custom 404 page
The other approach is taking the line above, adding it to an .htaccess file in the root of your website, and editing the files outlined above (000-default or httpd.conf), changing
AllowOverride Noneto
AllowOverride AllThen restarting apache2/httpd
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.