【问题标题】:How to block all other referer except localhost in web.confg如何在 web.config 中阻止除 localhost 之外的所有其他引用
【发布时间】:2020-07-06 22:42:06
【问题描述】:

我已在我的 web.config 中添加了一条规则来防止引用垃圾邮件。但我只想允许本地主机并阻止所有其他引用者。这是我正在尝试的,但它不起作用。

在此处输入代码

<system.webServer>
    <rewrite>
      <rules>
        <rule name="abort referer spam requests" stopProcessing="false">
          <match url="^localhost:49363$" />
                <conditions>
                    <add input="{HTTP_REFERER}" pattern="^localhost:49363$"  />
                </conditions>
                <action type="AbortRequest" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

【问题讨论】:

标签: asp.net asp.net-mvc url-rewriting iis-7


【解决方案1】:

请试试这个规则。

此规则将只允许空引用或本地主机并阻止从其他域引用的请求。

        <rule name="abort rule" enabled="true" stopProcessing="true">
            <match url="(.*)" />
            <conditions>
                <add input="{HTTP_REFERER}" pattern="(^$|localhost)" negate="true" />
            </conditions>
            <action type="AbortRequest" />
        </rule>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-04
    • 1970-01-01
    • 2022-12-17
    • 1970-01-01
    • 2023-03-17
    • 2021-01-24
    • 2014-03-20
    • 1970-01-01
    相关资源
    最近更新 更多