I saw several ways to rewrite $request_uri and add index.html to it when this particular file exists on the file system, for example:
if (-f $request_filename/index.html) { rewrite (.*) $1/index.html break; }
but I was wondering if the opposite is possible:
i.e. when someone requests http://example.com/index.html , they are redirected to http://example.com
Since nginx regexp is compatible with perl, I tried something like this:
if ( $request_uri ~* "index\.html$" ) { set $new_uri $request_uri ~* s/index\.html// rewrite $1 permanent; }
but this was mostly a hunch, is there any good documentation describing modrewrite for nginx?
source share