我想将非www和非https网址重定向到我的域https://www,我实际上在web.config中有以下内容,可以将非https重定向到https,但仍允许访问域.com没有www,
<rewrite>
<rules>
<clear />
<rule name="Default to root" stopProcessing="true">
<match url="(.*)default.aspx" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
我有共享托管..
答案 0 :(得分:0)
这是一个正在运行的代码
<rewrite>
<rules>
<clear />
<rule name="Default to root" stopProcessing="true">
<match url="(.*)default.aspx" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
<rule name="Add www" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^mydomain\.com$" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
谢谢@lexLi