Site url is not generated correctly when using environment variables I'm working on a multi-site setup (for a localized website). In my .env file, I have defined a SITE_BASE_URL variable. Then, in the control panel, I set up each site's base url with that environment variable (e.g. http://$SITE_BASE_URL/en, http://$SITE_BASE_URL/nl, etc. for each language).
However, when I need to generate urls in my Twig templates, this environment variable doesn't seem to get parsed; I get generated html that looks like this &lt;a href=&quot;http://$SITE_BASE_URL/en/services&quot;&gt;...&lt;/a&gt;.
Example from a twig template:
{% set pages = [
    craft.entries.section(&quot;services&quot;).one(),
    craft.entries.section(&quot;products&quot;).one(),
] %}

{% for page in pages %}
&lt;a href=&quot;{{ page.url }}&quot;&gt;{{page.title}}&lt;/a&gt;
{% endfor %}

This gives me URLs like http://$SITE_BASE_URL/en/services, http://$SITE_BASE_URL/en/products, etc.
This setup was working fine for me when using the @web alias in the CP. Why doesn't it work with the env variable? The only reason I switched to env variables is that it is not recommended to use the @web alias due to cache poisoning.
I've already looked at https://github.com/craftcms/cms/issues/3719 and baseUrl outputs environment variable
Neither have solved my issue...
Cache poisoning would only happen if you don't hard-set your @web alias manually and it is auto-determined.
Set it in your config/general.php with:
'aliases' =&gt; [
    'web' =&gt; getenv('SITE_BASE_URL'),
],

Then you'll be able to revert to using it in your Control Panel.
In terms of why this happened; you can't add to an environment variable the way you can with an alias so http://$SITE_BASE_URL/en will become a string and the variable aspect of it will disappear.
When you define $SITE_BASE_URL, it can only be used as is in the CP so if you wanted to use variables for you site, you would need to define one for each site/language.