【发布时间】:2021-12-28 13:08:55
【问题描述】:
我正在开发一个 MVC 项目,我的 web.config 中有以下工作规则,但它会将所有子域重定向到 https。我想做的是排除一些特定的子域。例如,我需要重定向“mywebsite.com”和“www.mywebsite.com”,而不是“test.mywebsite.com”或“beta.mywebsite.com”。排除的子域应保留为“http://test.mywebsite.com”和“http://beta.mywebsite.com”,而不被重定向到 https。我怎样才能做到这一点?这是我在 web.config 中的规则:
<rule name="Redirect to https" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/\.well-known/pki-validation/(.*)$" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="true" />
</rule>
【问题讨论】:
标签: redirect https web-config