首页  >  问答  >  正文

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

本人打算使用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       
}

请问可否详细说说?感谢

某草草某草草2714 天前843

全部回复(1)我来回复

  • 我想大声告诉你

    我想大声告诉你2017-05-16 17:11:29

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

    回复
    0
  • 取消回复