Multi-domain setup for one root page in TYPO3 10.4?

1.1k views Asked by At

I have problem configuring my old site which I upgraded from TYPO3 9.5 to 10.4. In TYPO3 9.5 I had a multidomain setup using one root page (a page with option is_siteroot set to true) and mapping multiple domains to this root page, so that e.g. the domains example.org, example.com and example.net all mapped to the same root page and thus showed the same content in frontend but had different urls. I was able to do that by configuring the root page as a site with domain example.org in the new site-module and then in the list module adding multiple domain records (example.org, example.com and example.net) to this root page.

Now the problem is, that after upgrading to TYPO3 10.4 the possibility to add domain records in the list module is no longer available and thus I'm not able to map multiple domains to the same root page. I can access the domain example.org that is configured in the site-module but now I wonder how I can configure the site so that also the domains example.com and example.net are mapped to the same root page.

The only possibility I currently see is to clone the whole page tree and then map the other domains to separate root pages. But the problem here is that all the content then has to be maintained in all three page trees and that is not a practicable solution for me because the content shown should be always the same for alle three domains.

Is it possible to configure this somehow, so that the domain mapping works again as described above?

Thanks in advance.

2

There are 2 answers

1
Jonas Eberle On BEST ANSWER

Caching might interfere with base paths containing variable parts.

I suggest to define multiple baseVariants. The conditions are not cached.

base: 'https://example.org'
baseVariants:
 - base: 'https://example.com'
   condition: 'getenv("HTTP_HOST") == "example.com"' 
 - base: 'https://example.net'
   condition: 'getenv("HTTP_HOST") == "example.net"' 

You can combine it with Mathias' idea to set an environment variable in .htaccess and use that instead, but it is actually not needed.

Disclaimer: Reacting to the HTTP Host might need adapting if behind an intransparent proxy. Yet it is very unusual nowadays that proxies are tinkering with Host - if they do, use X-Forwarded-Host instead.

4
Mathias Brodala On

One option would be adjusting your .htaccess file to set a suitable environment variable in case the requested HTTP host matches your expected list of hosts:

# Match any of example.org, example.com or example.net
# With other hosts TYPO3_BASE_HOST will be undefined 
SetEnvIfNoCase HOST ^(example\.(?:org|com|net))$ TYPO3_BASE_HOST=$1

Now you can use this environment variable as base in your site configuration:

base: 'https://%env(TYPO3_BASE_HOST)%/'

Notice however that having exactly the same content on multiple hosts will confuse users and lead to bad SEO rankings unless you set up proper canonical references.