Answer the question
In order to leave comments, you need to log in
How to compose Rewrite starting with a dot nginx?
Hello, there is such rewrite:
rewrite ^/(.+?)/(.+?)$ /cp.php?name=$1&nick=$2 last;
It contains the user's name and nickname. But it so happened that a nickname can start with a dot.
URL: test.ru/1/.Vasya. nginx throws a 403 Forbidden error.
URL: test.ru/1/Vasya. opens.
Is there any way to change the rewrite to force nginx to open links starting with . ?
Answer the question
In order to leave comments, you need to log in
The problem was in the last rule /\. , removed it and everything worked.
The dot is a special character in regular expressions, if you need to use the dot exactly as a dot, then you need to "escape" the dot \.
Something like this
rewrite ^/(.+?)/(\..+?)$ /cp.php?name=$1&nick=$2 last;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question