1

我想将来自http://www.example.com的所有流量重定向到http://www.mysite.com/badreferer.aspx?bad=true

为此,我尝试在 IIS7的http://www.mysite.com的 web.config 文件中创建规则。

<rule name="bad referer" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
                    <add input="{HTTP_REFERER}" pattern="(.*)example(.*)" />
      </conditions>
      <action type="Redirect" url="/badreferer.aspx?bad=true" appendQueryString="false" />          
    </rule>

但是重定向循环有问题。

请帮忙。

谢谢。

4

1 回答 1

1

尝试这个:

<rules>
  <rule name="bad referer" stopProcessing="true">
    <match url="^(.*)" />
    <conditions>
      <add input="{HTTP_REFERER}" pattern="http://www.example.com(.*)" negate="true" />
    </conditions>
    <action type="Redirect" url="http://www.website.com/badreferer.aspx?bad=true" />
  </rule>
</rules>

更新:

<rule name="bad referer" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
        <add input="{REQUEST_URI}" pattern="/badreferer\.aspx?bad=true" negate="true" />
        <add input="{HTTP_REFERER}" pattern="^www.\example\.com.*" />
    </conditions>
    <action type="Redirect" url="/badreferer.aspx?bad=true" appendQueryString="false" />
</rule>
于 2013-05-29T16:42:36.253 回答