RealURL Configuration Examples

This tutorial explains how to configure RealURL to work with a multiple-domain and/or a multilingual website.

Multiple Domain Configuration

Configuring RealURL in a multiple-domain TYPO3 tree installation led me to a few challenges.

I do have multiple domains ( www.paroisse.ch,  marly.paroisse.ch, …) stored in the very same TYPO3 tree. First question you may have is how accessing this TYPO3 “website” using different names. The configuration has to be done both in TYPO3and in Apache configuration.

Apache configuration consists simply of enumerating the domains to answer for.

In TYPO3, we need to somehow assign the domain(s) (e.g., with or without “www”) to the website root.

Configuring Apache

<VirtualHost *>

ServerName www.paroisse.ch
ServerAlias marly.paroisse.ch
ServerAlias arconciel.paroisse.ch


</VirtualHost>

Configuring TYPO3

In Web > List, for each website root, you need to add a “domain” record to the node.

In TypoScript template, for the whole tree, here is the configuration of the node CONFIGURATION:

config {
    ## RealURL with multiple domains and multiple roots
    no_cache = 0
    simulateStaticDocuments = 0
    tx_realurl_enable = 1
    baseURL = www.paroisse.ch
 
    ## Fix broken inter-domain links
    typolinkCheckRootline = 1
}

Then, for each domain, you need to create a Template with code below:

config.baseURL = http://marly.paroisse.ch/

We are near the end. You just have to edit the RealURL server-side configuration as described below. The RootPID array contains the list of tree domains and their corresponding root page ID.

$RootPID = array(
        'www.paroisse.ch' => '17',
        'paroisse.ch' => '17',
        'www.arconciel.paroisse.ch' => '41',
        'arconciel.paroisse.ch' => '41',
        'www.bonnefontaine.paroisse.ch' => '46',
        'bonnefontaine.paroisse.ch' => '46',
        'www.ependes.paroisse.ch' => '4',
        'ependes.paroisse.ch' => '4',
        'www.marly.paroisse.ch' => '1',
        'marly.paroisse.ch' => '1',
        'www.praroman.paroisse.ch' => '50',
        'praroman.paroisse.ch' => '50',
        'www.treyvaux.paroisse.ch' => '51',
        'treyvaux.paroisse.ch' => '51',
);
 
$TYPO3_CONF_VARS['FE']['addRootLineFields'] .=
    ',tx_realurl_pathsegment,alias,nav_title,title';
 
$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array();
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array(
        'init' => array(
                'enableCHashCache' => 1
                // disable enableUrlDecodeCache for multiple domains
                // as no root pid is caught and the system check to
                // see if correct page path is grabbed
                , 'enableUrlDecodeCache' => 0
                , 'enableUrlEncodeCache' => 0
                , 'appendMissingSlash' => 'ifNotFile'
                , 'respectSimulateStaticURLs' => 0
                , 'postVarSet_failureMode' => 'redirect_goodUpperDir'
        )
        , 'redirects'   => array()
        , 'preVars' => array(
                // stripped
        )
        , 'pagePath' => array(
                'type'                  => 'user'
                , 'userFunc'            =>
                      'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main'
                , 'spaceCharacter'      => '-'
                , 'languageGetVar'      => 'L'
                , 'rootpage_id'         =>
                      $RootPID[$_SERVER['HTTP_HOST']]
                , 'disablePathCache'    => 0
                , 'expireDays'          => 7
                , 'segTitleFieldList'   =>
                      'tx_realurl_pathsegment,alias,nav_title,title'
                , 'excludePageIds'      => null
        )
        , 'fixedPostVars'       => array()
      // stripped
);

Configuration multilingue

        'preVars' = array(
                array(
                        'GETvar'   = 'L',
                        'valueMap' = array(
                                'de' = '1',
                                'fr' = '2',
                                'it' = '3',
                        ),
                        'noMatch' = 'bypass',
                        //'valueDefault' = 'en',
                ),
        ),

With previous configuration, default language will not be prefixed in the URL. If you wish to force the language prefix in the URL, then remove line ’noMatch’ and uncomment the one with ’valueDefault’.

Flattr