4 ms·
I have had problems using rewrite in this way. The URL that rewrite analyses may have already been changed by `index` or some other command, and this will lead
by jcampbell1 13y ago
I have had problems using rewrite in this way. The URL that rewrite analyses may have already been changed by `index` or some other command, and this will lead to redirect loops. To avoid that problem, I have used:
if ($request_uri ~* "^(.*)\.html?$") {
return 301 $1;
}
The above is a safe use of "if", and can be helpful since it operates on the actual uri, not the internal uri.
- richardjs 13y agoThat's a good suggestion. Yeah, index directives will cause a redirect loop in my above configuration. The try_files directive is effectively taking the place of an index.