简体   繁体   English

URL重写模式,仅在不包含特定文件夹的情况下才匹配文件夹

[英]URL Rewrite pattern to match folder only when NOT preceded by specific folder

Excuse the poor title, but I'm not sure how to word this exactly. 不好意思的标题,但是我不确定该如何准确地表达。 Here's my scenario: 这是我的情况:

I've got this pattern: 我有这种模式:

(.*)MySpecialFolder(.*)

That I need rewritten to: 我需要重写为:

{R:1}MyOtherFolder/MySpecialFolder{R:2}

So http://localhost/MySpecialFolder/test.aspx will be rewritten as http://localhost/MyOtherFolder/MySpecialFolder/test.aspx 因此, http://localhost/MySpecialFolder/test.aspx将被重写为http://localhost/MyOtherFolder/MySpecialFolder/test.aspx

The problem is that on the next request, it still tries to replace MySpecialFolder again so it becomes http://localhost/MyOtherFolder/MyOtherFolder/MySpecialFolder/test.aspx , and so on. 问题在于,在下一个请求上,它仍然尝试再次替换MySpecialFolder ,因此它变为http://localhost/MyOtherFolder/MyOtherFolder/MySpecialFolder/test.aspx ,依此类推。

Is there a way I can update my regex pattern to say: 有什么办法可以更新我的正则表达式模式:

"Replace MySpecialFolder with MyOtherFolder/MySpecialFolder but ONLY when MySpecialFolder is not already preceded with MyOtherFolder/ "? “用MyOtherFolder/MySpecialFolder替换MySpecialFolder ,但是仅当MySpecialFolder MyOtherFolder/之前MyOtherFolder/ ”? So basically if MyOtherFolder/MySpecialFolder is already in the path, it doesn't see that as a "match". 因此,基本上,如果MyOtherFolder/MySpecialFolder已经在路径中,则不会将其视为“匹配项”。

添加条件以取消匹配MyOtherFolder

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

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