Reputation: 609
In TYPO3 9.5, I wanted to use config/sites/mysite/config.yaml
to dynamically serve different content for robots.txt
based on applicationContext
. Here's pseudocode for what I'm wanting to do but of course it doesn't work.
NOTE: I did find another place that tells how to do this via TypoScript, but I would prefer to do this in the yaml file or possibly with Fluid.
routes:
-
route: robots.txt
type: staticText
content: |
User-agent: *
Disallow: /fileadmin
Disallow: /search
Disallow: /typo3
Disallow: /typo3_src
Disallow: /typo3conf
Disallow: /typo3temp
Allow: /typo3/sysext/frontend/Resources/Public/*
Sitemap: /sitemap.xml
variants:
-
route: robots.txt
condition: 'applicationContext matches "#^(?!Production/Live)#"'
content: |
User-agent: *
Disallow: /
Upvotes: 0
Views: 737
Reputation: 76
I know this is not exactly what you are asking for but maybe with this approach you reach the same thing you are trying to achieve:
For the robots.txt file you got two options:
The official docs for static routes don't mention the condition syntax: https://docs.typo3.org/m/typo3/reference-coreapi/9.5/en-us/ApiOverview/SiteHandling/StaticRoutes.html (make sure you select the proper TYPO3 Version for the docs, as things change from major versions). Conditions are only described for the baseVariants and that is the only place I use them (and the forms extension, but that's something else).
Upvotes: 2