I want to add the proper 301 permanent redirect rule in IIS 8.5. I've added the following rules but it is not working.
<rule name="Redirect top domains with non-www to www" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern=".*localhost.*" negate="true" />
<add input="{HTTP_HOST}" pattern=".*stage..*" negate="true" />
<add input="{HTTP_HOST}" pattern=".*dev..*" negate="true" />
<add input="{HTTP_HOST}" pattern="^(http://){0,1}(www.){0,1}([^.]+).([^.]+)$" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://www.{C:3}.{C:4}" redirectType="Permanent" />
</rule>
Conditions
To summarize, every URL should be in HTTPS and should have "www." prefix.
NOTE: I have installed URL Rewrite Module in IIS.
Can anyone please help me to achieve this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…