rowan194 - 7:53 pm on Aug 20, 2012 (gmt 0)
I think I've figured it out. There is no need for per-site rewrite rules. All these lines are global in httpd.conf:
ScriptAliasMatch ^/robots.txt$ /var/www/robots-txt/handler.php
This sets the Apache handler for the file /var/www/robots-txt/handler.php to PHP, and maps a request for robots.txt (for any site) to /var/www/robots-txt/handler.php
And here's a sample handler which prints a smiley, then adds the original robots.txt file (if it exists)
echo "# :)\n";
if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/robots.txt")) readfile($_SERVER["DOCUMENT_ROOT"] . "/robots.txt");
edit: updated config to specifically only enable PHP for the one specific file, rather than an entire directory.