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

后端 未结 6 1430
孤街浪徒
孤街浪徒 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:39

    Try adding the following line after your index definition:

    error_page 404 /index.html;
    

    If that doesn't work, try changing your try_files call to the following instead:

    try_files $uri $uri/ /index.html;
    

    Hopefully one of those works for you, I haven't tested either yet.

提交回复
热议问题