简体   繁体   English

IIS URL HTTP 到 HTTPS 重定向不适用于 ASP.Net 应用程序

[英]IIS URL HTTP to HTTPS redirect not working on ASP.Net application

I have an ASP.Net application being hosted on a webserver with Plesk installed.我在安装了 Plesk 的网络服务器上托管了一个 ASP.Net 应用程序。

The application is hosted on a sub-domain (webapp.website.com) and the link to login to the system is supplied through the main domain website, so I haven't noticed this up until now.该应用程序托管在一个子域 (webapp.website.com) 上,登录系统的链接是通过主域网站提供的,所以直到现在我才注意到这一点。

If you type in webapp.website.com or http://webapp.website.com the website will connect to an unsecured page with the following error:如果您输入webapp.website.comhttp://webapp.website.com该网站将连接到一个不安全的页面,并出现以下错误:

Server Error 403 - Forbidden: Access is denied.服务器错误 403 - 禁止:访问被拒绝。 You do not have permission to view this directory or page using the credentials that you supplied.您无权使用您提供的凭据查看此目录或页面。

If you manually type in https://webapp.website.com (which is what the link is setup to do) the app connects just fine and works as expected.如果您手动输入https://webapp.website.com (这是设置链接的目的),应用程序连接正常并按预期工作。

I have enabled Permanent Redirect to HTTPS in Plesk, and have manually written a redirect rule in IIS Manager, but for some reason it seems to be ignoring this rule because the server connection is failing in HTTP and displaying the Server Error page instead.我在 Plesk 中启用了永久重定向到 HTTPS,并在 IIS 管理器中手动编写了重定向规则,但由于某种原因,它似乎忽略了此规则,因为服务器连接在 HTTP 中失败并显示服务器错误页面。

How can I resolve the redirect issue to either stop the error on HTTP, or for it to skip over and redirect to HTTPS?如何解决重定向问题以停止 HTTP 上的错误,或者让它跳过并重定向到 HTTPS?

I suspect there may be a problem with your rules, you can try the following rules:我怀疑您的规则可能有问题,您可以尝试以下规则:

      <rewrite>
            <rules>
                <rule name="Test" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="OFF" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>

This rule will redirect all http requests to https.此规则会将所有 http 请求重定向到 https。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM