【问题标题】:url rewrite - error This webpage has a redirect loopurl rewrite - 错误这个网页有一个重定向循环
【发布时间】:2013-05-25 01:01:35
【问题描述】:

我想将来自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>

但是重定向循环有问题。

请帮忙。

谢谢。

【问题讨论】:

    标签: iis-7 url-rewriting http-referer url-redirection


    【解决方案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>
    

    【讨论】:

    • 不起作用,它将我网站的所有链接重定向到该网址
    • 您是否将website.com 更改为您的网站名称?我认为 url="/badreferer.aspx?bad=true" 也应该工作
    • 为什么要否定="true"?这意味着与模式不匹配。
    • 重定向工作正常,但错误只是,mysite.com/badreferer.aspx?bad=true 的网页导致重定向过多。
    • 我只是在我的环境中进行测试,更新后的示例运行良好。
    猜你喜欢
    • 2014-12-27
    • 2013-12-22
    • 2013-11-06
    • 2013-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多