koninklijke-collective / my_redirects

TYPO3 Extension: Redirects management
https://typo3.org/extensions/repository/view/my_redirects
GNU General Public License v2.0
17 stars 20 forks source link

Redirects doesn't work on a multi root and multi domain setup #81

Open Simz opened 5 years ago

Simz commented 5 years ago

The problem is in the function getDefaultRootPageId(). This function only returns the _DEFAULT or the $configuration['defaultRootPageId'] but in a multi root multi domain context, it should return $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][GeneralUtility::getIndpEnv('HTTP_HOST')]. At least check if the array key exists.

ConfigurationUtility.php.txt

foobar13372 commented 5 years ago

Is #68 related?

witrin commented 5 years ago

Same problem here. It does not seems to work in a multi-site setup. Using TYPO3 8.7.19 and My Redirects 3.4.1.

Simz commented 5 years ago

Did you try my fix ?

djangones commented 5 years ago

@Simz, your fix worked for me! Thanks!

konnisoelch commented 4 years ago

Hi guys, i wonder why you use the RealUrl Config for that problem.

I would rather use the records in sys_domain since, they are always present in a multidomain system.

/**
     * Generate link based on current page information
     *
     * @param string $link
     * @return string
     * @todo future; refactor for TYPO3 9.x support
     */
    protected function generateLink($link)
    {
        try {
            $queryBuilder = $this->getQueryBuilderForTable('sys_domain');
            $statement = $queryBuilder->select('pid')->from('sys_domain')->where($queryBuilder->expr()->eq('domainName', $queryBuilder->createNamedParameter(GeneralUtility::getIndpEnv('HTTP_HOST'))))->execute();

            $rootPageId = ConfigurationUtility::getDefaultRootPageId($link);

            while ($row = $statement->fetch()) {
                $rootPageId = $row['pid'];
            }

            EidUtility::initializeTypoScriptFrontendController($rootPageId);
            list($url, $hash) = explode('#', $link, 2);
            // Remove hashbang and append at the end
            $_link = $this->getContentObjectRenderer()->typoLink_URL(
                ['parameter' => $url]
            );
            $link = $_link . ($hash ? '#' . $hash : '');
        } catch (\Exception $e) {
        }
        return $link;
    }
Simz commented 4 years ago

We want to use a multiple localized domains with different pids like website.en website.fr subsite1.fr subsite2.ru

On Tue., May 19, 2020, 3:40 a.m. Konstantin Sölch, notifications@github.com wrote:

Hi guys, i wonder why you use the RealUrl Config for that problem.

I would rather use the records in sys_domain since, they are always present in a multidomain system.

/**

  • Generate link based on current page information
  • @param string $link
  • @return string
  • @todo future; refactor for TYPO3 9.x support */ protected function generateLink($link) { try { $queryBuilder = $this->getQueryBuilderForTable('sys_domain'); $statement = $queryBuilder->select('pid')->from('sys_domain')->where($queryBuilder->expr()->eq('domainName', $queryBuilder->createNamedParameter(GeneralUtility::getIndpEnv('HTTP_HOST'))))->execute();

        $defaultRootPageId = ConfigurationUtility::getDefaultRootPageId($link);
    
        while ($row = $statement->fetch()) {
            $defaultRootPageId = $row['pid'];
        }
    
        EidUtility::initializeTypoScriptFrontendController($defaultRootPageId);
        list($url, $hash) = explode('#', $link, 2);
        // Remove hashbang and append at the end
        $_link = $this->getContentObjectRenderer()->typoLink_URL(
            ['parameter' => $url]
        );
        $link = $_link . ($hash ? '#' . $hash : '');
    } catch (\Exception $e) {
    }
    return $link;

    }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/koninklijke-collective/my_redirects/issues/81#issuecomment-630644466, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADPRCZC6G6ESO75SECULQDRSIZWLANCNFSM4GUPAB6Q .