Force .htaccess Redirect 404 Error server to Custom 404 Page
Sometimes you have a 404 messege problem reported when accessing the wrong path, but the server notification message doesn’t look right for you. So, how to redirect to a custom page or redirect to the home page of the website.
Here is the .htaccess rules
RewriteEngine On
ErrorDocument 404 /404.html
Code above redirect 404 server message to your 404.html page.
And here the htaccess rules for redirect 404 to homepage
RewriteEngine On
ErrorDocument 404 /
And here the htaccess rules for redirect 404 to an URL
RewriteEngine On
ErrorDocument 404 https://www.example.com/
THat’s all.
This article published on :