How to set index.html as root file in Nginx?

后端 未结 5 589
挽巷
挽巷 2020-12-08 09:14

How to set index.html for the domain name e.g. https://www.example.com/ - leads user to index.html in root directory.

I\'ve tried different things like:

         


        
5条回答
  •  广开言路
    2020-12-08 09:44

    in your location block you can do:

    location / {
      try_files $uri $uri/index.html;
    }
    

    which will tell ngingx to look for a file with the exact name given first, and if none such file is found it will try uri/index.html. So if a request for https://www.example.com/ comes it it would look for an exact file match first, and not finding that would then check for index.html

提交回复
热议问题