简体   繁体   English

正则表达式模式不支持#符号

[英]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. 我在Nginx配置中使用正则表达式来捕获文件URL,但如果文件URL包含#符号,则正则表达式模式将不会捕获它。

Here is the part of nginx config. 这是nginx配置的一部分。

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

}

An example file URL causing the error because it has # symbol in it. 导致错误的示例文件URL,因为它中包含#符号。

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

You need to change # to %23 in url: 您需要在URL中将#更改为%23

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

Here is complete list of URL Escape Characters 以下是URL转义字符的完整列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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