How do I set up custom 404 or 500 error pages? Print

To set up custom 404 or 500 error pages using the htaccess file for Apache, you can follow these steps:

  1. Create your custom error pages: Create the custom error pages in HTML or any other format you prefer. The two most common error pages are the 404 page and the 500 page. For example, you might create a 404.html page and a 500.html page.

  2. Upload the custom error pages: Upload the custom error pages to your server, in a directory accessible from the web. For example, you might upload the 404.html and 500.html pages to the root directory of your website.

  3. Edit the .htaccess file: Open or create the .htaccess file in the root directory of your website. Add the following lines of code to the file:

    ErrorDocument 404 /404.html
    ErrorDocument 500 /500.html

    These lines of code tell Apache to use the 404.html and 500.html files as the custom error pages for the 404 and 500 errors respectively.

    Make sure to replace "404.html" and "500.html" with the names of your actual error pages, and to include the correct path to these pages, relative to the root directory of your website.

  4. Save the .htaccess file: Save the .htaccess file and upload it to the root directory of your website if it wasn't already there.

After completing these steps, if a user encounters a 404 or 500 error on your website, they will be shown the custom error pages you created instead of the default Apache error pages.

Was this answer helpful?

« Back
Venatour Sports Travel

Encode have continually surpassed themselves in developing our new website. Their patience in learning and understanding what we needed from a website to provide the best service to our customers has been beneficial on so many levels. I would highly recommend them to anyone looking for intelligent solutions to their web, seo or business needs.

Lisa Cooley

Positive: Professionalism, Quality, Responsiveness, Value

Working with Neil is a dream; he's fast, efficient, responsive and full of website knowledge and advice. He won't baffle you with IT over load and will be honest about the best working solution.

Highly recommended!

Ellie Stevenson Author

Positive: Professionalism, Value

Encode and I had a very useful discussion about Wordpress and related issues at no cost to myself. He gave me some very helpful information and answered the questions I had.

I learnt quite a lot! Thank you.

Silvia Boev

Positive: Professionalism, Quality, Responsiveness, Value

I am very excited to work again with Neil. His attention to detail is second to none. I have seen his work in action in the past and he is great. I love his calm approach and his patient guidance to non-tech people like me. I would highly highly reccommend him!

Dr Fuz

Neil is the best! He has sorted out all our business emails and everything runs a great deal better now. Website issues are now a thing of the past as Neil has introduced a maintenance programme to ensure the site is always working optimally and any content changes are actioned pretty much immediately.

Highly recommended!!

H Scott-Brown

'Encode' provided my hosting and domain transfers. They were able to deal with the technicalities of the transfer in a particularly speedy manner, taking all the worry of the transfer, domain issues DNS and nameserver headaches as well as the migration. A couple of emails, and phone call meant it was done smoothly, swiftly and efficiently. All I can say is I'm really please they were recommended to me. Thank you