【问题标题】:Create a Global IIS 7 rewrite rule创建全局 IIS 7 重写规则
【发布时间】:2010-08-04 17:56:13
【问题描述】:

我的域有通配符 A 记录(**.*)指向我的开发机器。基本上,任何不是www 的子域都指向我的开发机器(根除外)。

我从不希望我的开发机器被搜索引擎索引或“关注”。

我想做的只是简单地设置一个 global URL 重写规则,如下所示:

<rule name="Global robots.txt rewrite" stopProcessing="true">
    <match url="^robots\.txt" ignoreCase="true" />
    <action type="Rewrite" url="http://localhost/robots.txt" />
</rule>

上面的规则不起作用;尽管以下重定向规则可以:

<rule name="GLobal robots.txt redirect" stopProcessing="true">
    <match url="^robots\.txt" ignoreCase="true" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^localhost$" negate="true" />
    </conditions>
    <action type="Redirect" url="http://localhost/robots.txt" />
</rule>

.. 但我不确定 301 重定向到 robots.txt 是否真的适用于搜索引擎。

关于如何完成我正在尝试的任何想法?

【问题讨论】:

    标签: iis-7 url-rewriting


    【解决方案1】:

    这看起来像是一篇很老的帖子,但我在搜索答案时发现了这个。您可以使用如下所示的规则来实现这一点:

    <rule name="Robots Disallow" stopProcessing="true">
       <match url="robots.txt" />
       <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
         <add input="{HTTP_HOST}" pattern="www" negate="true" />
       </conditions>
       <action type="Rewrite" url="robots_disallow.txt" />
    </rule>
    

    robots_disallow.txt 文件包含以下内容:

    User-agent: *
    Disallow: /
    

    【讨论】:

      猜你喜欢
      • 2014-09-16
      • 2014-05-01
      • 2014-08-22
      • 1970-01-01
      • 2021-08-22
      • 2014-01-05
      • 1970-01-01
      • 2012-05-15
      • 2011-05-07
      相关资源
      最近更新 更多