【问题标题】:IIS URL Rewrite Rule Excluding Multiple FilesIIS URL 重写规则排除多个文件
【发布时间】:2019-05-30 23:08:37
【问题描述】:

我有一个强制使用 HTTPS 的 IIS URL 重写规则,除非该页面是 healthcheck.html(通过端口 80)。这就像一个魅力,因为我使用匹配 URL 逻辑如下:

<match url="healthcheck.html" negate="true" />

但是,我不仅需要排除此页面,还需要在名为 Dir1 的目录中排除另一个名为 OtherCheck.aspx 的文件

我没有发现其他人排除了两个文件的任何实例,尤其是一个不在根目录中的文件。是否可以有两个文件名排除项?我试过了,但没有用:

<match url="healthcheck.html&/Dir1/OtherCheck.aspx" negate="true" />

【问题讨论】:

    标签: iis url-rewrite-module


    【解决方案1】:

    文件和文件夹结构: s1(根文件夹):

    healthcheck.html(文件)

    s2(子文件夹):

    page1.html(文件)

    您可以使用以下 url 重写规则来排除多个文件:

     <rule name="Redirect to HTTPS multiple file" enabled="true" stopProcessing="true">
         <match url="(.*)" />
         <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="off" />
                        <add input="{REQUEST_URI}" pattern="^/healthcheck.html" negate="true" />
                        <add input="{REQUEST_URI}" pattern="^/s2/page1.html" negate="true" />
         </conditions>
         <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
       </rule>
    

    https 重定向:

    排除文件:

    注意: 您可以根据需要设置文件和文件夹名称。

    问候, 哈尔帕

    【讨论】:

    • 完全有道理。优秀的例子和结构。由于这是 AppGateway 后面的 Azure VM,我还需要添加
    猜你喜欢
    • 2020-01-05
    • 1970-01-01
    • 2018-08-29
    • 2014-10-27
    • 2013-08-14
    • 2014-05-01
    • 2011-04-21
    相关资源
    最近更新 更多