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

前端 未结 7 669
[愿得一人]
[愿得一人] 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:37

    The following config allowed me to redirect /index.html to / and /subdir/index.html to /subdir/:

    # Strip "index.html" (for canonicalization)
    if ( $request_uri ~ "/index.html" ) {
        rewrite ^(.*)/ $1/ permanent;
    }
    

提交回复
热议问题