Z
Z
zoraxqq2018-11-11 13:54:47
Nginx
zoraxqq, 2018-11-11 13:54:47

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

2 answer(s)
Z
zoraxqq, 2018-11-11
@zoraxqq

The problem was in the last rule /\. , removed it and everything worked.

T
TyzhSysAdmin, 2018-11-11
@POS_troi

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 question

Ask a Question

731 491 924 answers to any question