IIS URL Rewrite for one spesific domain

Viewed 51

I have a rewrite rule that redirects users from mydomain.com/reset/test123 to mydomain.com/module.aspx?key=test123.

The rule works fine, and look like this:

<rule name="Reset" stopProcessing="true">
    <match url="^reset/([_0-9a-z-]+)" />
    <action type="Redirect" url="/module.aspx?key={R:1}" appendQueryString="false" />
</rule>

The only problem is that my website has multiple domains, and the rule runs for all of them. I need the rule to only run for mydomain.com.

I tried to change the match url to ^mydomain.com/reset/([_0-9a-z-]+), but this don't work.

How can I make the redirect to only run for one spesific domain?

1 Answers

Just add a condition under your <rule> element:

<conditions>
    <add input="{HTTP_HOST}" pattern="mydomain.com" />
</conditions>

See Documentation

Related