我需要将非www网址重定向到www网址,用于http和https网址.我尝试在web.config中遵循规则.
<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" />
Run Code Online (Sandbox Code Playgroud)
<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" />
Run Code Online (Sandbox Code Playgroud)
它适用于非ssl网址,但在ssl的情况下,它从https://domain.com重定向 到http://www.domain.com
请帮我纠正我的规则.