Reputation: 3
TYPO3 8.7.27 RealURL 2.5.0 English (id-0) and French (id=1) Multi Language Site
No matter what I do, RealURL keeps adding ?L=0 or ?L=1 to the end of every URL instead of actually creating real URLs. That is, I'm getting www.domain.com/page1/?L=0 instead of www.domain.com/en/page1
I've tried turning autoconf on and off, and I've read every piece of documentation out there, specifically Dmitry's own https://github.com/dmitryd/typo3-realurl/wiki/Notes-for-Integrators#configuring-languages
Here is the entire contents of /typo3conf/realurl_conf.php:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']['preVars'] => array(
array(
'GETvar' => 'L',
'valueMap' => array(
'en' => 0,
'fr' => 1,
),
'valueDefault' => 'en',
'noMatch' => 'bypass',
),
);
... and here is the relevent TypoScript:
config {
baseURL = {$BASE_URL}
absRefPrefix = {$BASE_URL}
tx_realurl_enable = 1
simulateStaticDocuments = 0
#linkVars = L(int)
sys_language_uid = 0
language = en
locale_all = en_US.UTF-8
htmlTag_langKey = en
#htmlTag_setParams = lang="en" dir="ltr" class="no-js"
linkVars = L
uniqueLinkVars=1
sys_language_mode = content_fallback
sys_language_overlay = 1
defaultGetVars {
L = 0
}
}
[globalVar = GP:L = 1]
config {
sys_language_uid = 1
language = fr
locale_all = fr_FR.UTF-8
htmlTag_langKey = fr
#htmlTag_setParams = lang="fr" dir="ltr" class="no-js"
}
[global]
page.19.variables.LANGUAGE = HMENU
page.19.variables.LANGUAGE {
special = language
special.value = 1,0
1 = TMENU
1 {
wrap = <ul id="language"> | </ul>
NO = 1
NO {
wrapItemAndSub = <li> | </li>
stdWrap.override = FR || EN
}
ACT < .NO
ACT {
ATagParams = class="active"
}
}
}
As an examnple, if I click on "page1" in the menu, I'm taken to: www.domain.com/page1/?L=0 (which confirms that realURL is working, but also indicates something is wrong)
I'm expecting, when I click on "page1" in the menu, I get taken to: www.domain.com/en/page1
Can anyone help me turn the "stuck" postVar into a proper preVar? Thank you very much in advance for any help you can provide!!!
EDIT/UPDATE 1: Thanks to Heinz, I now have www.domain.com/fr/page1 but ONLY if I manually enter it - it doesn't work automatically through menus, etc.
EDIT/UPDATE 2: I modified realurl_conf.php as follows (added the full code + encode at bottom) to get auto generation (see below) but now it's always adding ?L to the end. That is, result is always www.domain.com/fr/page1/?L=1 when it should be www.domain.com/fr/page1
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']= array (
'fixedPostVars' => array (
),
'pagePath' => array (
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'rootpage_id' => '1'
),
'init' =>
array (
'appendMissingSlash' => 'ifNotFile,redirect',
'emptyUrlReturnValue' => '/',
),
'pagePath' =>
array (
'rootpage_id' => '1',
),
'fileName' =>
array (
'defaultToHTMLsuffixOnPrev' => 0,
'acceptHTMLsuffix' => 1,
'index' =>
array (
'print' =>
array (
'keyValues' =>
array (
'type' => 98,
),
),
),
),
'preVars' =>
array (
0 =>
array (
'GETvar' => 'L',
'valueMap' =>
array (
'en' => '0',
'fr' => '1',
),
/*'valueDefault' => 'en',
'noMatch' => 'bypass',*/
),
),
'postVarSets' =>
array (
'_DEFAULT' =>
array (
'news' =>
array (
0 =>
array (
'GETvar' => 'tx_news_pi1[news]',
'lookUpTable' =>
array (
'table' => 'tx_news_domain_model_news',
'id_field' => 'uid',
'alias_field' => 'IF(path_segment!="",path_segment,title)',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'expireDays' => 180,
'enable404forInvalidAlias' => true,
),
),
),
),
),
);
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DOMAINS'] = array(
'encode' => array(
array(
'GETvar' => 'L',
'value' => '0', // en
'useConfiguration' => '_DEFAULT',
'urlPrepend' => '/en/'
),
array(
'GETvar' => 'L',
'value' => '1', // fr
'useConfiguration' => '_DEFAULT',
'urlPrepend' => '/fr/'
),
),
);
EDIT/UPDATE 3: If I do an .htaccess hack, I can get /en and /fr ... but it's ugly:
# Remove trailing ?L GET parameter from RealURL
RewriteCond %{QUERY_STRING} ^L=0$ [NC]
RewriteRule ^(.*)$ https://cmhw.stormiscoming.ca/en/$1? [R=301,L]
RewriteCond %{QUERY_STRING} ^L=1$ [NC]
RewriteRule ^(.*)$ https://cmhw.stormiscoming.ca/fr/$1? [R=301,L]
Upvotes: 0
Views: 396
Reputation: 2262
Some of your config are not needed anymore or does nothing. This should work:
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = array (
'init' => array (
'appendMissingSlash' => 'ifNotFile,redirect',
'emptyUrlReturnValue' => 1,
),
'preVars' => array (
array (
'GETvar' => 'L',
'valueMap' => array (
'en' => '0',
'fr' => '1',
),
),
),
'pagePath' => array (
'rootpage_id' => '1'
),
'fixedPostVars' => array (
),
'fileName' => array(),
'postVarSets' => array(
'_DEFAULT' => array (
'news' => array (
array (
'GETvar' => 'tx_news_pi1[news]',
'lookUpTable' => array (
'table' => 'tx_news_domain_model_news',
'id_field' => 'uid',
'alias_field' => 'IF(path_segment!="",path_segment,title)',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'expireDays' => 180,
'enable404forInvalidAlias' => true,
),
),
),
),
),
);
Upvotes: 0