Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TYPO3 RealURL: Two sites in an installation, both with one domain per language
<?php
$realUrlSiteConfigurations = [
'site1' => [
'rootPageUid' => 1,
'schema' => 'https',
'languageDomainMap' => [
0 => 'www.site1.ch',
1 => 'www.site1.fr',
2 => 'www.site1.it',
]
],
'site2' => [
'rootPageUid' => 2,
'schema' => 'https',
'languageDomainMap' => [
0 => 'www.site2.ch',
1 => 'www.site2.fr',
2 => 'www.site3.it',
]
]
];
# Could be used to override depending on global configuration, e.g. for staging/latest environment
#$realUrlSiteConfigurationOverrides = require_once(dirname(__FILE__) . '/../../Configuration/current/RealUrlConfiguration.php');
#\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($realUrlSiteConfigurations,
# $realUrlSiteConfigurationOverrides);
$realUrlDefaultConfiguration = [
'init' => [
'enableCHashCache' => 1,
'appendMissingSlash' => 'ifNotFile',
'enableUrlDecodeCache' => 1,
'enableUrlEncodeCache' => 1,
],
'redirects_regex' => [],
'preVars' => [
[
'GETvar' => 'no_cache',
'valueMap' => [
],
'noMatch' => 'bypass',
],
[
'GETvar' => 'L',
'valueMap' => [
'de' => '0',
'fr' => '1',
'it' => '2',
],
'noMatch' => 'bypass',
],
],
'pagePath' => [
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'expireDays' => 7,
'rootpage_id' => 1,
],
'fixedPostVars' => [],
'postVarSets' => [],
'fileName' => [],
];
foreach ($realUrlSiteConfigurations as $siteName => $realUrlSiteConfiguration) {
foreach ($realUrlSiteConfiguration['languageDomainMap'] as $languageUid => $domain) {
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$domain] = $realUrlDefaultConfiguration;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$domain]['pagePath']['rootpage_id'] = $realUrlSiteConfiguration['rootPageUid'];
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DOMAINS']['encode'][] = [
'rootpage_id' => $realUrlSiteConfiguration['rootPageUid'],
'GETvar' => 'L',
'value' => $languageUid,
'urlPrepend' => $realUrlSiteConfiguration['schema'] . '://' . $domain,
'useConfiguration' => $domain,
];
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DOMAINS']['decode'][$domain] = [
'GETvars' => [
'L' => $languageUid,
],
'useConfiguration' => $domain,
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment