正则表达式 - 请教个nginx正则替换的问题

浏览:50日期:2022-07-25

问题描述

本人打算使用nginx的subs_filter进行某些链接或者字符串的替换,但nginx的正则似乎和python之类的正则有点出入。。下面是试过的匹配

location / { #目的是将https://*.wikipedia.org替换成http://wiki.example.org subs_filter .wikipedia.org .wiki.example.org;#这个只能替换成https://wiki.example.org #也尝试过 subs_filter https://zh.wikipedia.org http://zh.wiki.example.org 但不行,会变成https://zhhttp://example.org }

请问可否详细说说?感谢

问题解答

回答1:

subs_filter https://(.*).wikipedia.org http://wiki.example.org ir;i表示忽略大小写r 表示前面是正则

相关文章: