I have multiple sites running on a single code base in Drupal 8. Is there any possible way to add different robots.txt file for each site?

  • I have multiple sites running on a single code care to mention how you managed to do this?
    – No Sssweat
    Jan 23, 2019 at 7:51

1 Answer 1


If you are under apache, you can use mod_rewrite to deliver others robots.txt :

  RewriteCond %{HTTP_HOST} ^domain1.com$
  RewriteRule ^robots.txt$ robots.domain1.com.txt [L]
  RewriteCond %{HTTP_HOST} ^domain2.com$
  RewriteRule ^robots.txt$ robots.domain2.com.txt [L]

Note you may also generate your robots.txt in some controller for each site depends on config and fallback to default if not defined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.