小编sar*_*rma的帖子

使用PCRE表达式重写URL - 将前缀附加到除一个模式之外的所有传入URI

我正在使用匹配表达式https://([^/]*)/(.*)并将表达式替换为constantprefix/$ 2并尝试通过向所有URL添加"/ constantprefix"来重写传入的URL

对于以下网址,它按预期工作:

  1. https:// hostname/incomingURI正在转换为/ constantprefix/incomingURI
  2. https:// hostname /正在转换为/ constantprefix/
  3. https://hostname/login/index.aspx正在转换为/constantprefix/login/index.aspx

我对已经以/ constantprefix开头的URL有问题,我在输出URL中看到两个/ constantprefix/constantprefix,我不想找,有什么办法可以避免吗?

如果传入的URL是https://hostname/constantprefix/login/index.aspx,那么输出的URL将变为https://hostname/constantprefix/constantprefix/login/index.aspx 我可以知道如何从匹配中避免/ constantprefix/constantprefix表达?

regex urlrewriter pcre regex-greedy

2
推荐指数
1
解决办法
344
查看次数

标签 统计

pcre ×1

regex ×1

regex-greedy ×1

urlrewriter ×1