lhan
lhan

Reputation: 4635

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

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.

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/"? So basically if MyOtherFolder/MySpecialFolder is already in the path, it doesn't see that as a "match".

Upvotes: 0

Views: 224

Answers (1)

Janaka
Janaka

Reputation: 28

Add a condition to unmatch MyOtherFolder

Upvotes: 1

Related Questions