Create a custom 404 (page does not exist) page for apache2 Ubuntu:


  1. 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
  2. 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.
  3. Edit the /etc/apache2/apache2.conf file and make these changes:
    1. remove comment sign if you find it before this line (near end of file):
      AccessFileName .htaccess
    2. 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.
    3. After saveing changes to that file, run command "sudo a2enmod rewrite" then "sudo /etc/init.d/apache2 restart".
  4. You now have your own custom error page!
Sources: Date: December 27th 2023


Back

© 2019 to 2025 Branden Gilfoil & © up to 2025 for respective owners.