TYPO3 force internal links to cross domain pages to use https in news

1.3k Views Asked by At

my TYPO3 website has multiple domains that have links from internal news to another a page in another domain.

Domain A (with SSL in frontend)
  Page 1
  News (folder)
  News A
  News B
Domain B (with SSL in frontend)
  Page 2
  Page 3

Links in News A to Page 1 work perfectly fine, but when linking from News B to Page 2 or Page 3, the url is generated properly, but the scheme is always http:

Example News A: <a href="/Page-1.html">Page 1</a>

Example News B: <a href="http://domain-b/Page-2.html">Page 2</a>

Is there a way to configure the url generation to always use https as scheme when linking to anything in a given domain? I suspect that this has to be done for the link rendering in tx_news?

1

There are 1 best solutions below

1
On

This has nothing to do with the news extension but is a bug in TYPO3 itself - or let's call it a missing feature because TYPO3 doesn't know at this place that the other domain should be use https as protocol.

What I do to solve this is a replace on the content before it is outputted. This can be done with adding a hook in the ext_localconf.php:

// Hook for changing output before showing it
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'][]
  = \Vendor\ExtKey\Hooks\Frontend\ContentPostProc::class . '->run';

and in the file typo3conf/extkey/Classes/Hooks/Frontend/ContentPostProc:

namespace Vendor\ExtKey\Hooks\Frontend;

class ContentPostProc
{

  public function run(array &$parameters) {
        $searchReplace = [
            'http://domain.tld' => 'https://domain.tld'
        ];
        $parameters['pObj']->content = str_replace(array_keys($searchReplace), array_values($searchReplace), $parameters['pObj']->content);
    }
}