首頁  >  問答  >  主體

正規表示式 - 請教個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       
}

請問可否詳細說說?感謝

某草草某草草2713 天前839

全部回覆(1)我來回復

  • 我想大声告诉你

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

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

    回覆
    0
  • 取消回覆