.htaccess 🔮 Customize the 404 error page

Share on email
Share on twitter
Share on linkedin
Share on facebook
Share on twitter
Share on linkedin
Share on facebook
Share on whatsapp
Share on email

Thanks to the.htaccess file, it is possible to customize the error pages of a site. Here we see how to customize the 404 error with a redirection to a selected page or by directly defining the displayed content.

Redirect 404 errors to a specific page

With the code below in the file .htaccess placed at the root of your site, the errors 404 will be redirected to the page /error/errors400.html.

# CUSTOM ERROR PAGES 
ErrorDocument 400 /error/errors400.html 

Directly define HTML content for 404 errors

The code below in the file .htaccess placed at the root of your site allows you to directly define the content that will be displayed in the event of a 404 error.

# CUSTOM ERROR PAGES 
ErrorDocument 400

"404 ErrorPage

not found

.... "

Julien MA Jacob
WordPress Developer
Julien MA JACOB - WordPress Developer
Passionate about the web and programming with always many projects in mind
  Discussion of the article
Subscribe to the newsletter
Notify to
guest
0 Comments
Inline Feedbacks
View all comments