I am using IIS URL Rewrite and this one has stumped me.

I am redirecting a URL with specific subfolder to a new URL.

e.g. https://myapp.example.com/customsite1 redirected to https://newsite1-myapp.example.com

If I use this pattern:


It works fine. The problem is there might be arguments added to the URL that also use the word customsite1. So I thought "of course, the easy way to fix to this is match on /customsite1"

But it never works.


will never match https://myapp.example.com/customsite1 even though the Test pattern feature says it will.

What am I missing here?

  • Please include the actual config directives you are using. What are the (.*) subgroups in your regex for?
    – MrWhite
    Dec 13, 2018 at 1:33

1 Answer 1


I guess you're referring to the Match URL pattern field, this one:

The first fields of the new rule editor

In that case the values received always start without the first / and don't include the Query String parameters either (if you need to make decisions based on the query string, it must be processed with a condition rule (using the {QUERY_STRING} field in the condition input).

So, if the arguments are added to the Query String it shouldn't worry you at all. If the arguments you're mentioning are part of the URL, for example:


then you should use a regular expression similar to this one:


This matches "/customsite1" with or without the final slash and anything that goes after it, and captures that part. It doesn't matter if any parts of the URL add the same name as the main folder you're trying to redirect.

In the "Redirect URL" field of the redirect action you can write:


The action URL

without the last slash since it is captured with the regular expression, and it will redirect request to that folder to the new domain, adding the rest of the URL after your folder.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.