Answer the question
In order to leave comments, you need to log in
How to write regular expressions for nginx rewrite?
Hello. Help write 2 regular expressions.
1. If the query string contains a dot in the last part (ignoring query parameters), then there should not be a trailing slash. For example:
/news/index.html
/top.news/item/123.htm
/test/test/te.st/test/any_text.any_text
/
/news/
/top.news/item/
/test/test/te.st/test/
/test/te.st/te.st/test/
rewrite ^(.*\.[^/]*)/$ $1 permanent;
Answer the question
In order to leave comments, you need to log in
The second, offhand, can be done like this:rewrite ^(.*/)?([^\.]*[^/])$ $1$2/ permanent;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question