Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TYPO3 targetDomain at rootpage #629

Open
bernd-reindl opened this issue Jun 13, 2018 · 2 comments
Open

TYPO3 targetDomain at rootpage #629

bernd-reindl opened this issue Jun 13, 2018 · 2 comments
Labels

Comments

@bernd-reindl
Copy link

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
  | )
  |  
  | )


@dmitryd
Copy link
Owner

dmitryd commented Jun 13, 2018

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.

@bernd-reindl
Copy link
Author

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', 
			), 
		)
	)
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants