Snippets

Tjerk Ameel Nginx robots.txt splitter

Created by Tjerk Ameel last modified
# Use website specific robots.txt files
location ~ ^/(robots.txt) {
        # Serve website 1 specific robots.txt file
        if ($http_host ~ ^(www\.)?website1.com) {
                rewrite  ^/robots.txt /robots_website1.txt last;
        }

        # Serve website 2 specific robots.txt file
        if ($http_host ~ ^(www\.)?website2.com) {
                rewrite  ^/robots.txt /robots_website2.txt last;
        }
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.