nginx : rewrite rule to remove /index.html from the $request_uri

前端 未结 7 662
[愿得一人]
[愿得一人] 2020-12-30 10:17

I\'ve seen a few ways to rewrite the $request_uri and add the index.html to it when that particular file exists in the file system, like so:

<
7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-30 10:43

    The solutions quoting $scheme://domain.com/ assume that the domain is hard-coded. It was not in my case and so I used:

    location / {
        ...
    
        rewrite index.html $scheme://$http_host/ redirect;
    
        ... }
    

提交回复
热议问题