I have written a simple url rewrite rule for my website hosted in IIS 10. It works perfectly without any issue.
However, there is a strange behavior. When I write url directly in the browser rule works fine, but if I search url in Google/Bing and then click the url on search page, rule didn't trigger.
I looked into Insights didn't find any relevant information.
Here is the rule -
<rule name="PROD Rule" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^myweb\.com$" />
</conditions>
<action type="Redirect" url="https://www.mywebsite.com/{R:0}" redirectType="Permanent" />
</rule>
Writing url directly in browser -
myweb.com redirects to https://www.mywebsite.com/
Searching url in search engine Google/Bing and then clicking url on search result page -
myweb.com stays at myweb.com
I was expecting that the rules should trigger whenever request reaches IIS irrespective of source of origin.
So it turns out to be not a problem related to search engines. Instead it was just a missed case by rewrite rules I have written.
Existing rules were expecting myweb.com as input and correctly redirecting them to https://www.mywebsite.com/
However, when I search same url on search engine and click on them. Url send to server is NOT myweb.com instead www.myweb.com
Here is an update rules which worked -
<rule name="PROD Rule" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^myweb\.com$" />
<add input="{HTTP_HOST}" pattern="^threeinsure\.com$" />
</conditions>
<action type="Redirect" url="https://www.mywebsite.com/{R:0}" redirectType="Permanent" />
</rule>