Apache: serving different robots.txt for SSL and non-SSL version of the website

From lxadm | Linux administration tips, tutorials, HOWTOs and articles
Jump to: navigation, search

Sometimes, you may want SSL (https://) version of your websites to have different robots.txt than the plain text version (http://).

Here is how to achieve it with Apache webserver:

        # serve different robots.txt for https
        RewriteEngine On
        RewriteCond %{HTTPS} =on
        RewriteRule ^/robots\.txt$ /robots_ssl.txt [L]