Redirect 404 to Homepage using .htaccess

Apache provides ErrorDocument directive to help you catch all types of error responses. So if you want to redirect all 404 errors to a specific web page (e.g http://www.example.com/error.html) just add the following line to your .htaccess file.

ErrorDocument 404 http://www.example.com/error.html

If you want to redirect 404 to URL (e.g /error) instead of a specific web page, then add the following line

ErrorDocument 404 /error

Leave a Comment

Your email address will not be published. Required fields are marked *

Open chat