Pretty new to this, but trying hard to understand.
I was able to redirect non-www to www, and http to https, but now I need to redirect a domain pointer to the primary. ie Domain2.com to Domain1.com. I am concerned about the URL chain and taking a hit on SEO. Should I put the domain redirect before the WWW\\https one?
<rule name="Force WWW and SSL" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^[^www]" />
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://www.domain1.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
<!-- Just add this? Should it go in front of the other? -->
<rule name ="Redirect Domain2 to Domain1" enabled="true">
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="domain2.com" />
</conditions>
<action type="Redirect" url="https//www.domain1.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
Instead two rules you can create one rule with multiple conditions:
<rule name="All in one rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="^www\.domain1\.com$" negate="true" />
</conditions>
<action type="Redirect" url="https://www.domain1.com{URL}" />
</rule>
This rule will do the following:
www.domain1.com
This rule will make only one necessary redirect instead of multiple redirects as your current rules
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.