Contao: How can I change the protocol of the base url?

不想你离开。 提交于 2019-12-03 22:45:30

Contao uses the following to determine whether the current request is done via SSL or not » \Environment::get('ssl'):

/**
 * Return true if the current page was requested via an SSL connection
 *
 * @return boolean True if SSL is enabled
 */
protected static function ssl()
{
    return ($_SERVER['SSL_SESSION_ID'] || $_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1);
}

It is possible that your server environment does not set either of these $_SERVER globals. This can be the case if you are using an SSL proxy for example.

If that is the case for you, then you can extend the SSL detection by inserting

if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO']) 
{
    $_SERVER['HTTPS'] = 1;
}

into your /system/config/initconfig.php. See https://github.com/contao/core/issues/7542 for example (only German though).

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