想知道是否有人可以提供帮助。非常感谢!
问题:
- blog.example.com
cool.example.com
重定向到 https://www.example.com
目标:
我们试图只重定向
http://example.com
http://www.example.com
到 https://www.example.com
当前代码
web.config 中的当前代码是这样的。停留在 <match url="(.*)">
以下是重写规则的其余部分。
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to https">
<match url="(.*)" />
<conditions>
<add input="{SERVER_PORT}" pattern="443" negate="true" />
</conditions>
<action type="Redirect" url="https://www.example.com" />
</rule>
</rules>
</rewrite>
<modules runAllManagedModulesForAllRequests="true"/>
<defaultDocument enabled="true">
<files>
<clear/>
<!--Remove this line or place below to deprecate-->
<add value="default.aspx"/>
<add value="index.html"/>
<add value="index.php"/>
<add value="default.html"/>
</files>
</defaultDocument>
最佳答案
修改<match url="(.*)" />
仅包含 example.com
和 www.example.com
- 现在您正在匹配所有网址。
http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module/
关于asp.net - 仅一个 URL 的 HTTP 到 HTTPS 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9508588/