Iis 7 创建全局IIS 7重写规则

Iis 7 创建全局IIS 7重写规则,iis-7,url-rewriting,Iis 7,Url Rewriting,我有指向我的开发机器的域的通配符A记录(*和*.)。基本上,任何不是www的子域都指向我的开发机器(根目录除外) 我从不希望我的开发机器被索引或被搜索引擎“跟踪” 我想做的是简单地设置一个全局URL重写规则,如下所示: <rule name="Global robots.txt rewrite" stopProcessing="true"> <match url="^robots\.txt" ignoreCase="true" /> <action

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

我从不希望我的开发机器被索引或被搜索引擎“跟踪”

我想做的是简单地设置一个全局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是否真的适用于搜索引擎


关于如何完成我正在尝试的事情有什么想法吗?

这看起来像是一篇非常古老的帖子,但我在寻找答案时发现了这一点。您可以使用如下规则来实现这一点:

<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>
User-agent: *
Disallow: /