.htaccess 🔮 Customize 404 error page

Share on twitter
Share on linkedin
Share on facebook
Share on whatsapp
Share on email
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 chosen 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 .htaccess placed at the root of your site allows you to directly define the content that will be displayed in case of a 404 error.

# CUSTOM ERROR PAGES 
ErrorDocument 400

"404 ErrorPage

not found

... "

Julien .MA Jacob
Developer WordPress
Julien MA Jacob - Developer WordPress
🧙♂️ Passionate about the web and programming with always lots of projects in mind 👨💻 | About page
  Discussion of the article
Subscribe to our newsletter
Notify of
guest
0 Comments
Inline Feedbacks
View all comments