不允许在我的环境中安装URL Rewrite,因此,我找到了另一条路径。
将此添加到我的web.config中,添加了错误重写并可以在IIS 7.5上工作:
<system.webServer>
<httpErrors errorMode="Custom" defaultResponseMode="File" defaultPath="C:\WebSites\yoursite\" >
<remove statusCode="403" subStatusCode="4" />
<error statusCode="403" subStatusCode="4" responseMode="File" path="redirectToHttps.html" />
</httpErrors>
然后,按照此处的建议进行操作:https : //www.sslshopper.com/iis7-redirect-http-to-https.html
我创建了执行重定向的html文件(redirectToHttps.html):
<html>
<head><title>Redirecting...</title></head>
<script language="JavaScript">
function redirectHttpToHttps()
{
var httpURL= window.location.hostname + window.location.pathname + window.location.search;
var httpsURL= "https://" + httpURL;
window.location = httpsURL;
}
redirectHttpToHttps();
</script>
<body>
</body>
</html>
我希望有人觉得这很有用,因为我无法在其他任何地方的某个地方找到所有作品。