带子域的 IIS 重写(http 到 https)

发布于 2024-10-01 12:39:06 字数 462 浏览 3 评论 0原文

我找到并尝试了这里找到的杰夫规则,但我可以'让它完全正常工作:

我需要的是让 http://abcom 转到 https://abcom (其中 a 不是 www,但这种区别不应该真正影响规则,不是吗?www 只是另一个子域,对吧?)

Jeff 有 (.*)billing/(.*) 的地方,我用 (.*) 替换,但这不起作用。

我尝试的结果产生“重定向循环”错误。

这种重写对我来说是新的。

感谢您的所有帮助。

I found and tried Jeff's rules found here but I can't get it to work exactly right:

What I need is to have http://a.b.com go to https://a.b.com (where a is not www, but that distinction shouldn't really affect the rule, should it? www is just another subdomain, right?)

Where Jeff has (.*)billing/(.*), I replaced with (.*), but that's not working.

The results of my attempts produce "redirect loop" errors.

This rewriting stuff is new to me.

Appreciate all your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦醒时光 2024-10-08 12:39:06

您应该确保您的应用程序(发送到 http://abcom/ 直接发送到 https://abcom/),而不是使用重定向,否则,相同请求将在重定向到 HTTPS 之前通过纯 HTTP 传输,这违背了这一点。

(此这个其他问题了解更多详细信息.)

Rather than using redirections, you should make sure your application (that sends to http://a.b.com/ sends to https://a.b.com/ directly), otherwise, the same request will go over plain HTTP before being redirected to HTTPS, which defeats the point.

(This this other question for more details.)

淡忘如思 2024-10-08 12:39:06

好吧,这不完全是您要求的答案,但如果您有机会在 ASP.net 页面上使用它,您可以打开 Global.ASPX 文件,然后在“Application_BeginRequest”页面中输入:

    Dim url As New System.UriBuilder(Context.Request.Url)

    'Do our redirect if we need
    If Context.Request.IsSecureConnection = False Then

        url.Scheme = "https"
        url.Port = -1
        System.Web.HttpContext.Current.Response.Redirect(url.Uri.ToString())

    End If

Well not exactly the answer you are asking for, but if you by any chance are using this on an ASP.net page, you can open your Global.ASPX file and inside the "Application_BeginRequest" page you can put:

    Dim url As New System.UriBuilder(Context.Request.Url)

    'Do our redirect if we need
    If Context.Request.IsSecureConnection = False Then

        url.Scheme = "https"
        url.Port = -1
        System.Web.HttpContext.Current.Response.Redirect(url.Uri.ToString())

    End If
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文