我想将http://www.example.com,http : //example.com或https://www.example.com重定向到https://example.com。如何使用web.config文件执行此操作?
安装URL重写模块(默认情况下不安装)。http://www.iis.net/downloads/microsoft/url-rewrite
一旦有了这些,就可以在web.config中的system.webServer / rewrite / rules下设置一个规则部分。添加此规则:
<rule name="Redirect www to domain" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{HTTP_HOST}" pattern="^www.example.com" />
</conditions>
<action type="Redirect" url="https://example.com/{R:1}" />
</rule>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句