IIS中的HTTP重定向问题,继续在浏览器上获取ERR_TOO_MANY_REDIRECTS [英] HTTP redirection issue in IIS, keep getting ERR_TOO_MANY_REDIRECTS on the browser

查看:975
本文介绍了IIS中的HTTP重定向问题,继续在浏览器上获取ERR_TOO_MANY_REDIRECTS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在IIS上的网站上启用HTTPS。我想将用户从http重定向到https。

I am trying to enable HTTPS on a website on IIS. I want to redirect the user from http to https.

我已在web.config中相应更新规则

I have updated the rule accordingly in web.config to

<rewrite>
        <rules>
            <rule name="Redirect to HTTPs" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="^OFF$" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}/" redirectType="Permanent" />
            </rule>
        </rules>
</rewrite>

我能够将请求转换为https,但随后它会使用https重定向到同一个网址。问题是该规则显然保持重定向所有网址,包括https,然后网络选项卡中的浏览器保留大量301并最终抛出

I am able to convert the request to https but then it keeps redirecting to the same url with https. The problem is that the rule apparently keeps redirecting all urls including to https and then the browser in the network tab keeps lots of 301 and eventually throws

This webpage has a redirect loop

ERR_TOO_MANY_REDIRECTS

ERR_TOO_MANY_REDIRECTS

如果有人解决了类似情况,请在这里帮助我。如有必要,我可以提供更多信息。

Please help me out here if someone has tackled a similar situation. I can provide more information if necessary.

谢谢

推荐答案

请尝试以下重写规则。这适用于由单个IIS服务器提供服务的网站。负载均衡的环境或服务器公司需要一些调整。

Try the following rewrite rule. This will work for websites served by single IIS server. Load balanced environments or server firms need some tweaks.

<rewrite>
    <rules>
        <rule name="Redirect to HTTPs" enabled="true" stopProcessing="true">
            <match url="(.*)" />
            <conditions>
                <add input="{HTTPS}" pattern="OFF" />
            </conditions>
            <action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
        </rule>
    </rules>
</rewrite>

您还可以查看问题和解决方案 here

You can also have a look at the question and solution here

这篇关于IIS中的HTTP重定向问题,继续在浏览器上获取ERR_TOO_MANY_REDIRECTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆