Skip to content

Instantly share code, notes, and snippets.

@netProphET
Last active November 25, 2015 19:42
Show Gist options
  • Save netProphET/610bef9c90133564e4be to your computer and use it in GitHub Desktop.
Save netProphET/610bef9c90133564e4be to your computer and use it in GitHub Desktop.
Used in the "web rules" in MODX Cloud, this set of directives allows you to serve robots.txt requests from MODX for your production hostnames, but blocks robot access on the modxcloud.com hostnames. This can be useful if you have a multi-context site and wish to serve different robots.txt responses per context/hostname.
# Pass robots.txt requests to MODX unless the hostname matches modxcloud.com
# Note: robots.txt files on the filesystem will be completely ignored
set $roboloco "@modx-rewrite";
if ($host ~* modxcloud\.com) {
set $roboloco "@robots-disallow";
}
location ~ ^/robots\.txt$ {
try_files foobar $roboloco;
}
# Standard MODX rewrite
location / {
try_files $uri $uri/ @modx-rewrite;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment