Attempting to use URL Rewrite module in IIS 10 on a Windows 10 VM to inject/add a response header if the domain is NOT the "www." domain but it's not getting added. There are several bindings on this site and we only want pages indexed when the url visited is www.[mydomain.com]
This is the only rule on this site, so there aren't any other rules to interfere.
Here's the rule:
<rewrite>
<rules>
<rule name="Add X-ROBOTS-TAG Header">
<match url="^.*$" />
<conditions>
</conditions>
<serverVariables>
<set name="X-ROBOTS-TAG" value="noindex, nofollow" replace="false" />
</serverVariables>
<action type="Rewrite" url="{R:0}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
For the regex pattern, I have also tried (.*)
and .*
. I also tried switching to wildcards and just putting *
and that didn't work either.
I have used DevTools to find whether the header is being added and also used the Chrome extension HTTP Headers
but they both agree that it's not being added.
I have examined the IIS logs and I cannot find that the rule is being triggered at all (I searched the log for the word "rewrite" and it's not there).
What might I have wrong?