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

apache-2.4htpasswdhttphttps

I got a small site which served by Apache (I can't put Nginx in front nor change Apache to anything), and it is set up to serve the same site both over http and https (no redirects http->https is there so far, so both http and https versions are served in parallel).

What I need is to set up .htaccess so the same URI via http and via https to serve different text file?

Like http://example.com/proto.txt says "The site is over http" while https://example.com/proto.txt would say "The site served over https".

Best Answer

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"