How do I force redirect all 404's (or every page, whether invalid or not) to the homepage?

后端 未结 6 1435
孤街浪徒
孤街浪徒 2020-12-07 19:06

Currently every invalid page is 500 (Internal Server Error) because I probably messed up with my server block configuration.

I decided to shut down my website a whil

6条回答
  •  遥遥无期
    2020-12-07 19:42

    Hi first there are a lot of different ways to redirect all the 404 to the home page this helps you in SEO make such u use

     fastcgi_intercept_errors on;
    

    than add this following to your config

            error_page 404 =301 http://yourdomain.com/;
        error_page 403 /error403.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /var/www/html;
    
        }
    

提交回复
热议问题