While it is possible to implement a solution with physical files, this approach has some disadvantages:
- To apply a change you have to physically change a file on the server.
- If you have scaled setup with multiple CD server, you would have to apply changes to robots.txt on each of the servers.
In contrary, if you generate robots.txt files on the fly based on a hostname and store robots.txt content in Sitecore items, you would have a central place to manage, which would work across all your CD servers.
If you still wanna go for a file-based solution, you could consider using IIS URL rewrite module:
- Have a robots.txt file per website, e.g site1.robots.txt, site2.robots.txt
- Setup IIS rewrite rules to process the /robots.txt requests and rewrite file path based on the hostname.
From top of my head, this could look something like this:
<rule name="Multisite robots.txt">
<match url="^robots\.txt$" />
<action type="Rewrite" url="{HTTP_HOST}.robots.txt" />
</rule>
And if you decide to go for dynamic robots.txt generation, there are tons of examples you can find in the internet, e.g https://sitecoreclimber.wordpress.com/2014/07/27/sitecore-multisite-robots-txt/ or even Marketplace modules https://marketplace.sitecore.net/Modules/U/Ultimate_Sitemap_XML.aspx