简体   繁体   中英

Regex pattern does not support # symbol

I use regex in Nginx configs to capture file urls but if the file URL contains the # symbol, regex pattern will not capture it.

Here is the part of nginx config.

location ~ ^/p/(?<secure>[\w\-=]+,\d+),(?<user>[^/]+)(?<file>/.*)$ {

}

An example file URL causing the error because it has # symbol in it.

http://mydomain.com/p/KPFHELPFAQrc3rUPIUS7Cg,1401267921,1/4962/Ubuntu#6 (DVD-ISO)/Ubuntu-12-04.iso

You need to change # to %23 in url:

http://mydomain.com/p/KPFHELPFAQrc3rUPIUS7Cg,1401267921,1/4962/Ubuntu%236 (DVD-ISO)/Ubuntu-12-04.iso

Here is complete list of URL Escape Characters

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM