Answer the question
In order to leave comments, you need to log in
How to process with nginx URL with spaces?
Website on VDS: CentOS, nginx, PHP.
The site has this link:
http://www.site.ru/%D0%91%D1%80%D1%8...20%D0%9B%D0%B8
I need to convert this address to the following form on the server :
http://www.site.ru/index.php?title=%...20%D0%9B%D0%B8
or
http://www.site.ru/index.php?title=Bruce Lee
For I wrote the following rule in nginx.conf:
rewrite ^/([a-pr-ya-zA-Z0-9_- ]+)/$ /index.php?title=$1;
But this rule doesn't work. Probably due to the fact that on the server the address is automatically decoded and cannot process a space.
I tried to write the rule in different ways: I escaped the space, wrote it as \%20 or as "plus", or \s - nothing comes out.
Can you tell me how to teach nginx to handle spaces?
Or how to disable automatic decoding in nginx (I can decode the string using PHP).
Or maybe it's possible to somehow replace all spaces on the nginx side before rewriting with, say, "plus", and then I'll convert it back to PHP.
Thank you!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question