我正在處理一個 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>
uj5u.com熱心網友回復:
我曾經有一個類似的配置,在這條線上使用了一條規則:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="redirect to https2" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^subdomain\.example\.com$" negate="true" />
<add input="{HTTPS}" pattern="off" ignoreCase="false" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{URL}" redirectType="Found" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/399414.html
上一篇:基于GCP上的引數重定向請求
