Skip to content

Instantly share code, notes, and snippets.

@manishjaingit
Forked from lorenzulrich/realurl_conf.php
Created August 12, 2017 07:38
Show Gist options
  • Save manishjaingit/6181d2e8bf7daee116aa8466f2b5ec34 to your computer and use it in GitHub Desktop.
Save manishjaingit/6181d2e8bf7daee116aa8466f2b5ec34 to your computer and use it in GitHub Desktop.
TYPO3 RealURL: Two sites in an installation, both with one domain per language
<?php
$site1De = 'www.foo.de';
$site1DeWithPrefix = 'http://' . $site1De;
$site1Fr = 'www.foo.fr';
$site1FrWithPrefix = 'http://' . $site1Fr;
$site1It = 'www.foo.it';
$site1ItWithPrefix = 'http://' . $site1It;
$site2De = 'www.bar.de';
$site2DeWithPrefix = 'http://' . $site2De;
$site2Fr = 'www.bar.fr';
$site2FrWithPrefix = 'http://' . $site2Fr;
$site2It = 'www.bar.it';
$site2ItWithPrefix = 'http://' . $site2It;
$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] .= ',tx_realurl_pathsegment,alias,nav_title,title';
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array(
$site1De => array(
'init' => array(
'enableCHashCache' => true,
'appendMissingSlash' => 'ifNotFile,redirect',
'adminJumpToBackend' => true,
'enableUrlDecodeCache' => true,
'enableUrlEncodeCache' => true,
'emptyUrlReturnValue' => '/'
),
'pagePath' => array(
'type' => 'user',
//'disablePathCache' => true,
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'rootpage_id' => '1'
),
'fileName' => array(
'defaultToHTMLsuffixOnPrev' => 0,
'acceptHTMLsuffix' => 0
),
'preVars' => array(
array(
'GETvar' => 'L',
'valueMap' => array(
'de' => 0,
'fr' => 1,
'it' => 2
),
'valueDefault' => 'de',
'noMatch' => 'bypass'
)
),
'postVarSets' => array(
'_DEFAULT' => array(
)
)
),
);
if (preg_match('/www\.(site1)\.(?:(ch|fr|it))$/', $_SERVER['HTTP_HOST'])) {
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DOMAINS'] = array(
'encode' => array(
array(
'GETvar' => 'L',
'value' => '0',
'useConfiguration' => $site1De,
'urlPrepend' => $site1DeWithPrefix,
'ifDifferentToCurrent' => 'true'
),
array(
'GETvar' => 'L',
'value' => '1',
'useConfiguration' => $site1Fr,
'urlPrepend' => $site1FrWithPrefix,
'ifDifferentToCurrent' => 'true'
),
array(
'GETvar' => 'L',
'value' => '2',
'useConfiguration' => $site1It,
'urlPrepend' => $site1ItWithPrefix,
'ifDifferentToCurrent' => 'true'
),
),
'decode' => array(
$site1De => array(
'GETvars' => array(
'L' => ''
),
'useConfiguration' => $site1De
),
$site1Fr => array(
'GETvars' => array(
'L' => '1'
),
'useConfiguration' => $site1Fr
),
$site1It => array(
'GETvars' => array(
'L' => '2'
),
'useConfiguration' => $site1It
),
)
);
} else {
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DOMAINS'] = array(
'encode' => array(
array(
'GETvar' => 'L',
'value' => '0',
'useConfiguration' => $site2De,
'urlPrepend' => $site2DeWithPrefix,
'ifDifferentToCurrent' => 'true'
),
array(
'GETvar' => 'L',
'value' => '1',
'useConfiguration' => $site2Fr,
'urlPrepend' => $site2FrWithPrefix,
'ifDifferentToCurrent' => 'true'
),
array(
'GETvar' => 'L',
'value' => '2',
'useConfiguration' => $site2It,
'urlPrepend' => $site2ItWithPrefix,
'ifDifferentToCurrent' => 'true'
)
),
'decode' => array(
$site2De => array(
'GETvars' => array(
'L' => ''
),
'useConfiguration' => $site2De
),
$site2Fr => array(
'GETvars' => array(
'L' => '1'
),
'useConfiguration' => $site2Fr
),
$site2It => array(
'GETvars' => array(
'L' => '2'
),
'useConfiguration' => $site2It
)
)
);
}
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$site1Fr] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$site1De];
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$site1It] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$site1De];
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$site2De] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$site1De];
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$site2De]['pagePath']['rootpage_id'] = 6;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$site2Fr] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$site2De];
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$site2It] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$site2De];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment