Search code examples
typo3realurl

TYPO3 RealUrl: select pagetree and language from url segment


We have multiple pagetrees for each region (e.g. Germany, Suisse). The pages themselves are translated to several languages (e.g. de, en) using the L-Parameter.

Now Realurl should match from 2 url segments to the approriate page tree and language. I know how this can be done with separate domains for each region using the _Domains feature. But in this case the domain stays always the same for all regions. Can this be achieved with Realurl and how?

http://example.com/de/de => should map to pagetree with rootpage_id 1 and language de (L=0)

http://example.com/de/en => should map to pagetree with rootpage_id 1 and language en (L=1)

http://example.com/ch/de => should map to pagetree with rootpage_id 2 and language de (L=0)

http://example.com/ch/en => should map to pagetree with rootpage_id 2 and language en (L=1)

real_url.conf

<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = array(
    'init' => array(
        'enableCHashCache' => 1,
        'appendMissingSlash' => 'ifNotFile,redirect',
        'adminJumpToBackend' => 1,
        'enableUrlDecodeCache' => 1,
        'enableUrlEncodeCache' => 1,
        'emptyUrlReturnValue' => '/'
    ),
    'pagePath' => array(
        'type' => 'user',
        'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
        'spaceCharacter' => '-',
        'languageGetVar' => 'L',
        'expireDays' => '3',
        'rootpage_id' => 1,
        'firstHitPathCache'=>1
    ),
    'preVars' => array(
        array(
            'GETvar' => 'L',
            'valueMap' => array(
                'de' => '0',
                'en' => '1',
            ),
            'valueDefault' => 'de',
        ),
       array(
            'GETvar' => 'no_cache',
            'valueMap' => array(
                'no_cache' => 1,
            ),
            'noMatch' => 'bypass',
        ),
    ),
);

Solution

  • Now Realurl should match from 2 url segments to the approriate page tree and language.

    RealURL cannot do that. Root page id is determined before segments are processed. It is defined by the domain record or your RealURL configuration.