How to configure multiple domains for same Root Page ID within Site Configuration?

Viewed 1258

I have a rootpage which should be accessible by multiple domains. These domains are aliases (no variants, based on conditions). In former versions of TYPO3, you could have multiple sys_domain-records on a rootpage, and the one on top was taken for building absolute URLs.

How can one configure that behavior now?

(I know, it would be better to have a single domain per website because of duplicate content and so on...)

4 Answers

You can extend the conditions for base variants with the current host to switch your base URL depending on the current host.

I uploaded a small extension that you can use for that:

https://github.com/b13/host_variants

This is working for me in typo3conf/sites/sitename/config.yaml (TYPO3 V10) :

base: 'http://site.de/'
baseVariants:
  -
    base: 'http://alias.de/'
    condition: 'getenv("HTTP_HOST") == "alias.de"'

to further this selection I have following in setup.ts:

# Multidomain
config.baseURL = http://site.de/
config.absRefPrefix = http://site.de/

[request.getNormalizedParams().getHttpHost() == "alias.de"]
  config.baseURL = http://alias.de/
  config.absRefPrefix = http://alias.de/
[global]

If you use the other domains only as alias and want to redirect to on main domain you could to that with Rewrites in .htaccess.

If you want to access the tree with all domains you could use:

base: /
baseVariants:
  -
    base: 'https://www.xxx.de/'
    condition: 'applicationContext == "Production"'
  -
    base: 'https://www.yyy.de/'
    condition: 'applicationContext == "Production"'
  -
    base: 'https://www.zzz.de/'
    condition: 'applicationContext == "Production"'

Combined with a config.baseURL of the main domain you should be able to achive the same behaviour as with the sys_domain records.

If you need different baseURLs you can use for each host. Without the need of extra extensions.

[request.getNormalizedParams().getHttpHost() == 'www.yyy.de']
config.baseURL = https://www.yyy.de/
[end]
Related