[英]Redirection from Http to Https works only internally on iis server browser where is app installed
Redirection from http to https not working properly, below is my code used in web.config file从 http 到 https 的重定向无法正常工作,下面是我在 web.config 文件中使用的代码
<rewrite>
<rules>
<rule name="http to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Temporary" />
</rule>
</rules>
</rewrite>
I have a valid SSL certificate, and I disable Require SSL.我有一个有效的 SSL 证书,并且我禁用了 Require SSL。
with this code in global.asax file在 global.asax 文件中使用此代码
protected void Application_BeginRequest()
{
if (!Request.IsSecureConnection)
{
Response.Redirect(Request.Url.AbsoluteUri.Replace("http://", "https://"));
}
}
I tried all argument but nothing works, redirection works only if I open the browser from the server it self.我尝试了所有参数,但没有任何效果,只有当我从服务器打开浏览器时,重定向才有效。
You could do the same from the IIS Manager:您可以从 IIS 管理器执行相同操作:
Open IIS Manager -> Select your site from Connections Panel (in left side) -> Click on HSTS... option from Action Panel(in right side) -> Check the "Enable" Option and "Redirect Http to Https" -> Now click the "OK" button.打开 IIS 管理器 -> 从连接面板(左侧)中选择您的站点 -> 从操作面板(右侧)中单击 HSTS... 选项 -> 选中“启用”选项和“将 Http 重定向到 Https” ->现在单击“确定”按钮。
Hope it will work for you.希望它对你有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.