Monday, September 18, 2023

How to redirect 404 error to the home page

 How to redirect 404 error to the home page

Following steps helps to redirect all 404 error pages to the home page. Assume you already installed httpd in this server.

  • Make sure you enabled "rewrite_modile" (httpd - M | grep rewrite)
  • vi /etc/httpd/conf/httpd.conf (enable AllowOverride from "None" to "All"). Based on your configuration path.
  • vi /var/www/html/.htaccess (ErrorDocument 404 https://example.com)
  • systemctl restart httpd
  • Test it

No comments:

Post a Comment