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?
1 Answer
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.
I have multiple sites running on a single code
care to mention how you managed to do this?