-2

I have a multisite setup.

public html
 - Sites 
 - - All
 - - site1.com
 - - site2.com
etc.

I need to .txt files to the root of each website such as site1.com/ads.txt or site2.com/robots.txt

If I upload to public_html the .txt file will be accessible on all sites on the installation. If I install in the individual files folder the .txt file is shown as site1.com/sites/site1.com/files/filename.txt.

How can I show the .txt file at the root of site1.com but not site2.com?

  • 1
    drupal.org/project/robotstxt creates dynamic robots.txt per instance. You then may want to copy their approach in a custom module to do the same for ads.txt. Or you simply provide your own route /ads.txt with its own controller to serve the content dynamically from a custom module. – leymannx Aug 19 at 21:19
0

I have multisite installation and there are multiple common code or files I am able to access in each site.

  • You can add your common php, txt or html etc files in the rootsite folder(or you can make assets directory and specify the path "/assets/ads.txt" while accessing) and just try to access e.g site1.com/ads.txt site2.com/ads.txt.

  • Another thing is you can create pages using page-ui, page-manager modules (for templates, html or php pages).

  • Also you can write controller for the common page and in controller class just simply use the markup to render that page and add routing path for the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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