1

I'm trying to set up IIS to redirect traffic from https://sub.foo.com to https://www.foo.com, but NOT redirecting any traffic to https://sub.foo.com/bar. The regular HTTP redirect module doesn't allow this kind of control (https://sub.foo.com/bar will be redirected) so I'm trying to use the URL Rewrite module, but despite much Googling, I can't find the right settings.

Currently my rule looks like this (I don't have the rep to embed images sadly) but isn't working. I've tried setting it at the server level and on both the "to" and "from" sites, but still no luck. What have I missed?

1

You can use the following regex pattern to match only requests where the path part of the URI is empty:

^$

Put it into the "Match URL" field

Use a Condition to make sure it only applies to requests for the sub.foo.com domain by matching on the {HTTP_HOST} server variable. Pattern should be something like ^sub\.foo\.com$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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