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

纵然是瞬间 提交于 2019-12-11 17:25:12

问题


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:


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


来源:https://stackoverflow.com/questions/49749397/typo3-force-internal-links-to-cross-domain-pages-to-use-https-in-news

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!