【问题标题】:force http to https for specific subfolders using web.config IIS使用 web.config IIS 将特定子文件夹的 http 强制为 https
【发布时间】:2017-03-21 20:43:18
【问题描述】:

在使用 Windows 2006 R2 的 VPS 上,我想编辑 web.config 文件,以便在多个子文件夹中找到的所有页面都从 http 重定向到 https。

我在下面找到了这个建议,我想知道的是如何列出将应用此重写规则的特定文件夹。

子文件夹是:

/secure1/

/secure2/

/admin1/

/admin2/

任何帮助和建议将不胜感激:)

<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <clear />
            <rule name="Redirect to https" stopProcessing="true">
                <match url=".*" />
                <conditions>
                    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

【问题讨论】:

  • 您好 NepCoder,感谢您的解决方案。我会在今天晚些时候尝试并反馈。
  • 你能让它工作吗?
  • 您好!感谢您的跟进。这是一个疯狂忙碌的一周,我打算早点回来报告。代码就在...服务器重写模块然而是另一回事哈哈。经过一番研究,似乎有一些解决方法,但它们需要我目前没有的专业水平。几个月后我会将该站点迁移到 Windows 2012 环境,然后我会再次测试所有内容。再次感谢您的帮助:)
  • 很高兴听到这个消息。如果它对您有用,那么您介意接受我的回答吗?如果其他人处于类似情况,这将对其有所帮助。谢谢。

标签: iis web-config windows-server-2008


【解决方案1】:

这样的事情怎么样?

<rule name="test" stopProcessing="true">
    <match url="(secure1|secure2|admin1|admin2).*" />
    <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>

如果您想了解更多信息,请从该网址获取信息: https://forums.iis.net/t/1176994.aspx?Https+Redirect+for+certain+folders+sections+only

【讨论】:

    猜你喜欢
    • 2015-11-16
    • 1970-01-01
    • 2018-08-28
    • 1970-01-01
    • 2018-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-29
    相关资源
    最近更新 更多