Asp.net IIS中的http到https
我意识到这是一个简单的问题,但我只是没有找到答案。我已经应用了下面的规则Asp.net IIS中的http到https,asp.net,iis,webforms,web-config,webserver,Asp.net,Iis,Webforms,Web Config,Webserver,我意识到这是一个简单的问题,但我只是没有找到答案。我已经应用了下面的规则 <rewrite> <rules> <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <ad
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
所以
重写的结果是
因此,重写正在删除目录
我假设{R:1}指定了一个将被重写的参数,并尝试了https://{HTTP_HOST}/{R:1}/{R:2},但这会导致500错误
我想将此域上的所有流量定向到https,而不更改用户输入的url的其余部分。以下是我们在其中一个站点上使用的将所有流量自动重定向到https版本的方法。它还包括url中的所有其他内容
<rewrite>
<rules>
<clear />
<rule name="Redirect to https" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="true" />
</rule>
</rules>
</rewrite>
{R:1}和{R:2}(etc)表示用于匹配URL的正则表达式的捕获组。您没有第二个捕获组,这就是{R:2}未定义的原因。
<rewrite>
<rules>
<clear />
<rule name="Redirect to https" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="true" />
</rule>
</rules>
</rewrite>