我有一个IIS服务器,用于通过TeamCity运行的CI。我非常希望我的域名上的任何网址被重定向到该网址的HTTPS版本。
我已经阅读了这里链接的教程:http://www.jppinto.com/2010/03/automatically-redirect-http-requests-to-https-on-iis7-using-url-rewrite-2-0/
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" negate="true" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
<rule name="Subdirectory HTTP to HTTPS redirect" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(^admin/.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>此外,这是我的web.config的当前版本,遵循本教程:
我真的不确定我做错了什么,因为我的域名的主urls似乎重定向到https,但许多子域只有404,除非你显式指定HTTPS。任何帮助都将不胜感激!
发布于 2015-03-31 22:44:40
请看下面的例子,包括截图(链接)。不安全的默认文档也应该是index.htm。
<!DOCTYPE html><html>
<!-- This is index.htm -->
<head><script>
if (window.location.protocol != "https:") {
window.location.protocol = "https:";
window.location.reload();
}</head></html>ASP重定向解决方案:
<% Response.Redirect "https://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") %>
PHP重定向解决方案:
<?php header('HTTP/1.1 302 Found'); header('Location: https://' . $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI]); ?>
IIS站点中的处理程序配置:Handler config
不安全站点中的错误页面:Custom error pages
https://stackoverflow.com/questions/29370878
复制相似问题