typo3-realurl icon indicating copy to clipboard operation
typo3-realurl copied to clipboard

TYPO3 targetDomain at rootpage

Open bernd-reindl opened this issue 6 years ago • 2 comments

Hello,

i have an RealURL configuration, where the URL is created like this: www.domain.tld/path/

The function encodeUrl returns '/' als path for the rootpage and set [/] => urlPrependValue to $urlPrependRegister. TYPO3 prepends the targetDomain to this url an calls postProcessEncodedUrl postProcessEncodedUrl remove the domain with the preg_replace function and the result is an empty string, because the first "/" after the domain was removed.

So if (isset(self::$urlPrependRegister[$testUrl])) failes, because testUrl is ''(empty) and not '/' like in the urlPrependRegister.

This only happens at the rootpage, because other pages have no prepending '/'. [somepath/] => urlPrependValue

To solve this problem, i add this code to the UrlEncode.php after the preg_replace

if($testUrl === '')
                $testUrl = '/';

Find my modifications in UrlEncoder.php by searching for [BEGIN]Added by Reindl UrlEncoder.zip

Debuginfo

Array
--
  | (
  | [finalTagParts-url] => https://www.starpumpalliance.com/
  | [testUrl] =>
  | [urlPrependRegister] => Array
  | (
  | [/] => https://de.starpumpalliance.com
  | )
  |  
  | )


bernd-reindl avatar Jun 13 '18 07:06 bernd-reindl

If you are alone, who gets this, than this is a problem local to your installation. This means that the fix will not be made to realurl, most likely.

dmitryd avatar Jun 13 '18 16:06 dmitryd

I dont think i am alone. But this configuration is rare.

You have to configure a MultiLanguage system with domains as language switch. And if the path generation is configured to generate a path wihout ".html" e.g. "/path1/path2/" the path for the root is always "/"

$urlPrependRegister contains now [/] => de.domain.tld

TYPO3\CMS\Frontend\Typolink\PageLinkBuilder prepends the targetDomain to this path / => http://www.domain.tld/

postProcessEncodedUrl in UrlEncoder.php process now the finalTagParts from PageLinkBuilder and removes the domain from the url. / => http://www.domain.tld/ => '' (empty)

if (isset(self::$urlPrependRegister[$testUrl])) failes because '' (empty) is not in $urlPrependRegister.

$testUrl should never be '' (empty) because an empty value could never be an array key

maybe there is an other solution for this issue, but this one works perfect for me.

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DOMAINS'] => array(
	'encode' => array(
		array( 
			'GETvar' => 'L', 
			'value' => '0', 
			'useConfiguration' => 'www.starpumpalliance.com', 
			'urlPrepend' => 'https://www.starpumpalliance.com', 
			'rootpage_id' => 9,
		),
		array( 
			'GETvar' => 'L', 
			'value' => '2', 
			'useConfiguration' => 'www.starpumpalliance.com', 
			'urlPrepend' => 'https://de.starpumpalliance.com', 
			'rootpage_id' => 9,
		)
	),
	'decode' => array( 
		'www.starpumpalliance.com' => array(
			'useConfiguration' => 'www.starpumpalliance.com', 
			'GETvars' => array( 
				'L' => '0', 
			), 
		),
		'de.starpumpalliance.com' => array(
			'useConfiguration' => 'www.starpumpalliance.com', 
			'GETvars' => array( 
				'L' => '2', 
			), 
		)
	)
);

bernd-reindl avatar Jun 14 '18 08:06 bernd-reindl