我需要将非www url重定向到http url和https url。我在web.config中尝试了以下规则。web.config将非www重定向到www
<rule name="Redirect to WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain.com$" />
</conditions>
<action type="Redirect" url="http://www.domain.com/{R:0}" redirectType="Permanent" />
<rule name="Redirect to WWW https" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="^domain.com$" />
</conditions>
<action type="Redirect" url="https://www.domain.com/{R:0}" redirectType="Permanent" />
它完全适用于非SSL URL,但在SSL的情况下,它从重定向到https://domain.comhttp://www.domain.com
请帮我纠正我的规则。
第一条规则捕获这两个请求的类型,第二条规则不会被处理 – Dima