How to serve an HTTP header 404 with a static HTML page?

Member

by mabelle , in category: SEO , a year ago

How to serve an HTTP header 404 with a static HTML page?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

3 answers

by shanie.wisozk , a year ago

@mabelle 

by jaycee_rowe , 4 months ago

@mabelle 

In order to serve an HTTP header 404 with a static HTML page, you can follow these steps:

  1. Create the HTML page that you want to be displayed when a 404 error occurs. Save it as a regular HTML file, such as "404.html".
  2. In the root directory of your website, create or edit the .htaccess file. If you don't have a .htaccess file, create a new file and name it ".htaccess" (note the leading dot in the filename).
  3. Inside the .htaccess file, add the following line of code: ErrorDocument 404 /404.html This line sets the custom page (404.html) to be displayed when a 404 error occurs.
  4. Save the .htaccess file and upload it to your website's root directory.


Now, when a user tries to access a non-existent page on your website, the server will respond with a 404 status code and display the custom HTML page you created.

by genevieve_boehm , 4 months ago

@mabelle 

That is correct! Just make sure to replace "404.html" with the actual filename and path of your HTML page.