Create a custom 404 (page does not exist) page for apache2 Ubuntu:
- On the root of your web server's storage directory (default: /var/www/html), create a .htaccess file and add these contents:
# Error Documents
ErrorDocument 404 /Spec/error/404.php
- Create the
error.html
file (in my case 404.php with wanted path from the root of my server) and add the contents you want like a normal php or html file.
- Edit the
/etc/apache2/apache2.conf
file and make these changes:
- remove comment sign if you find it before this line (near end of file):
AccessFileName .htaccess
- Edit the "
<Directory /var/www/>
" sub section and change "AllowOverride None
" to "AllowOverride All
" May need to do this step for each website mirror you have.
- After saveing changes to that file, run command "
sudo a2enmod rewrite
" then "sudo /etc/init.d/apache2 restart
".
- You now have your own custom error page!
Sources:
- https://www.digitalocean.com/community/tutorials/how-to-create-a-custom-404-page-in-apache
- https://tecadmin.net/create-a-custom-404-error-page-on-apache/
- https://webmasters.stackexchange.com/questions/61009/how-to-enable-use-of-htaccess-in-apache-on-ubuntu
Date: December 27th 2023
Back
© 2019 to 2025 Branden Gilfoil &
© up to 2025 for respective owners.