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

自古美人都是妖i 提交于 2019-12-05 09:34:33

问题


In Contao 3.5.9

I have uploaded to new server and am using a different domain from the original installation. I am also using https://

Many of the resources needed are not being loaded because the system has the base url set to http:// It is using the correct domain name in the base url, but the wrong protocol.

I cannot login to the admin.

I searched Google (not much there about Contao) and found this: http://blog.qzminski.com/article/move-the-contao-to-another-server.html

reading it, it seems that the base url is set in the admin, which means it can be found somewhere in the db.

I have search the DB dump but cannot find it.

How can I change the protocol of the base url?


回答1:


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



来源:https://stackoverflow.com/questions/36773112/contao-how-can-i-change-the-protocol-of-the-base-url

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