我要求我们的网站主机在我们的网站上设置SSL,这样HTTP请求将自动redirect到HTTPS。
他们说这是完成,但是当通过HTTP访问网站时,我现在得到:
Response HTTP/1.1 403 Forbidden
HTTPS工作正常。
我问这是纠正,我被告知这不是一个服务器设置(他们pipe理),需要通过web.config(我有权访问)修复。
我已经尝试使用以下更改来捕获这个403并redirect它:
<system.web> <customErrors defaultRedirect="/test.html" mode="On"></customErrors> </system.web> <httpErrors errorMode="Custom"> <remove statusCode="403" subStatusCode="-1" /> <error statusCode="403" prefixLanguageFilePath="" path="/test.html" responseMode="ExecuteURL" /> </httpErrors>
如何解决这个问题,HTTP将redirect到 – 有效地要求 – HTTPS?
事实certificate,主机必须首先取消选中“需要SSL”,然后我能够通过web.configredirectstream量:
<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>