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
    Commented Jan 23, 2019 at 7:51

3 Answers 3


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.


The RobotsTXT module lets you have a different robots.txt for each site in a multisite setup. It also gives you the chance to edit via the UI.

  1. You need to have 2 modules:
  1. Enable RobotsTxt and Domain Configuration UI modules.

  2. On the RobotsTxt configuration form (https://[your_website]/admin/config/search/robotstxt) you should see a "Enable domain configuration" button. Just click on the button.

  3. After, you will see a "Domain Configuration" container at the top of the RobotsTxt configuration page where you can switch between domains and apply related configuration.

Your Answer

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

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