I would like the following URLs on my site to be equivalent:
/foo/bar /foo/bar/ /foo/bar/index.html
and further I would like the second two forms to issue HTTP 301 redirects to the first form. I am just serving static pages, and they are arranged according to the third form. (In other words, when a user requests
/foo/bar they should receive the file at
nginx.conf currently contains the following:
rewrite ^(.+)/$ $1 permanent; index index.html; try_files $uri $uri/index.html =404;
This works for requests for
/foo/bar/index.html, but when I request
/foo/bar/ Safari tells me that “too many redirects occurred”—I assume there’s an infinite redirect loop or something like that. How can I get nginx to map URLs to files in the way I’ve described?
Edit: My full configuration
Here is my entire
nginx.conf with my domain name replaced with “example.com”.