I use Drupal 8 and I want serve statics files in each multiple sites with Nginx.

I've a site at web/sites/site_1/ and a site at web/sites/site_2/.

I want serve ads.txt or robots.txt for each sites with different content.

I can add directory in site_1/statics/ with files and serve this files at root with Nginx but I don't know how I can to do this.

Is it possible to do this with Nginx? Or is there some other way?


It maybe is possible with Nginx but Nginx config is off-topic. Please have a look at the RobotsTxt module instead. The RobotsTxt module simply provides you a /robots.txt route that behaves just like a normal robots.txt file with the difference that you can configure the content of it from the back-end per site. You only need to pay attention that you deleted the physical robots.txt file to let the RobotsTxt module do its work.

Use this module when you are running multiple Drupal sites from a single code base (multisite) and you need a different robots.txt file for each one. This module generates the robots.txt file dynamically and gives you the chance to edit it, on a per-site basis, from the web UI.

Note: You must delete or rename the robots.txt file in the root of your Drupal installation for this module to display its own robots.txt file(s).

This solves your robots.txt problem. The ads.txt needs to be solved the same way. You need to create a custom module that does just the same as the RobotsTxt module for the /ads.txt route. With an admin settings form to store its content.

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