Create an IIS 7 Global Rewrite Rule

I have A wildcard entries ( * and *.* ) For my domain pointing to my dev machine. Basically, any subdomain that is not www points to my dev machine (except the root).

I never want my dev machine to be indexed or "tracked" by search engines.

What I would like to do is simply configure the Rewrite global URL rule as follows:

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

The rule above will not work; although the following redirection 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> 

.. but I'm not sure 301 redirects to robots.txt really work for search engines.

Any ideas on how to accomplish what I'm trying to do?

+4
source share
1 answer

This seems like a really old post, but I found this while searching for an answer. You can achieve this using a rule that looks like this:

 <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> 

The robots_disallow.txt file has the following:

 User-agent: * Disallow: / 
+3
source

All Articles