HTTPS 重定向不能正常工作
HTTPS Redirect not working quite right
我在 ASP.NET web.config 文件中使用以下代码将 "www" 请求重定向到我的安全网站:
<rewrite>
<rules>
<clear/>
<rule name="httpsredirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{REQUEST_URI}" />
</rule>
</rules>
</rewrite>
目标是确保当有人进入时
他们被重定向到
。
问题是重定向在将它们发送到安全站点时工作正常,但缺少目标 URI,因此它们被发送到站点的根默认页面。这里有什么帮助吗?谢谢!
现在
尝试更改
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{REQUEST_URI}" />
至
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
如果您查看答案 here,您会发现他们有 url="https://{HTTP_HOST}{REQUEST_URI}"
而不是您的 url="https://{HTTP_HOST}/{REQUEST_URI}"
。
我在 ASP.NET web.config 文件中使用以下代码将 "www" 请求重定向到我的安全网站:
<rewrite>
<rules>
<clear/>
<rule name="httpsredirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{REQUEST_URI}" />
</rule>
</rules>
</rewrite>
目标是确保当有人进入时
他们被重定向到
。
问题是重定向在将它们发送到安全站点时工作正常,但缺少目标 URI,因此它们被发送到站点的根默认页面。这里有什么帮助吗?谢谢! 现在
尝试更改
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{REQUEST_URI}" />
至
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
如果您查看答案 here,您会发现他们有 url="https://{HTTP_HOST}{REQUEST_URI}"
而不是您的 url="https://{HTTP_HOST}/{REQUEST_URI}"
。