How to configure Apache2 to Use Custom Error Pages on Ubuntu?


Creating your custom error page

Now let’s dive in adding a custom error page to your site.

Sample Code

<!DOCTYPE html>

<html>

<body>

<h1>404</h1>

<a href="index.html” class=”err-btn”><i class=”fas fa-angle-right”></i></a>

</div>

</body>

</html>

You can also make your own version of 404 html page more visually appealing

Implement the 404 Page

Now that you have your custom error page coded (referred to as 404.html from here on), Now quickly go to the home directory /var/www/html/.

The next step is editing your Apache localized-error-pages file to use 404.html instead of the default error page.

Locate your localized-error-pages configuration file in the/var/www/html/.directory. The file will be called localized-error-pages.conf

Now you can see there are different types of error pages that can be overridden. Just uncomment line 8 that starts with “ErrorDocument 404” and add “/404.html” instead of the default location for that error page. You can simply repeat this or create different custom error pages for each type of error.

Save and Exit Once Done

ErrorDocument 404 /404.html

Now the last step is to restart your Apache server in order for the changes to take effect:

sudo service apache2 restart

See the 404 Page

Now visiting unavailable pages on your site should display your custom 404 page!

Categories

Looking for a Top Rated* Marketing Company?

Contact us at +1 630 999 (7768) or submit a business inquiry online.

NectarSpot team executed the Quick and solid build of AMP website. Not afraid of small tweaks here and there. The team has, from the beginning of project, focus on conversion and provided a seamless workflow for my prospects to visit, educate and finally purchase on my e-commerce portal. They provided design, development on AMP framework and helped to host e-commerce portal on scalable and secure google cloud. We are looking forward to working with them in future for other projects as well.

Read More....

Ryan Frederickson

Art Wine Preserver

Start Your Project Today (100% Satisfaction Guaranteed)

  • NectarSpot Inc. is an integrated digital marketing agency specializing in Design & Development of Web, Mobile & Voice Applications.
    We excel in providing Optimization, Automation, PPC & Analytics services to high performing brands across industries.

    Contact us today at +1 630 999 (7768) or email at info@nectarspot.com to know more.

Need help?

We are right here!