How to serve different robots.txt for http and https on same site?

Use an Alias

Create two files, robots.txt and robots_http.txt and add this to your http VirtualHost:

Alias "/robots.txt" "/path/to/documentroot/robots_http.txt"

If you can't or won't change the "main" Apache config but need to do it in a .htaccess file, you can use a RewriteRule with a RewriteCond that checks for HTTPS.

Something along the lines of:

RewriteEngine On

RewriteCond %{HTTPS} "on"
RewriteRule robots.txt robots_https.txt [L]

should probably work (I didn't test it).

Note that this is based on Apache doing HTTPS termination itself. If HTTPS termination is done on a reverse proxy before it, then the condition will likely be different (and will depend on the configuration of the reverse proxy and Apache).