After setting up an Amazon Elastic Load Balancer, where SSL terminates, I was getting Mixed Content errors on the site, until I added the following line to wp-config.php
.
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
While this fixed the Mixed Content errors, now I get this PHP Notice after using wp-cli:
PHP Notice: Undefined index: HTTP_X_FORWARDED_PROTO in phar:///opt/bitnami/apps/wordpress/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1169) : eval()'d code on line 81
What should I do?
After setting up an Amazon Elastic Load Balancer, where SSL terminates, I was getting Mixed Content errors on the site, until I added the following line to wp-config.php
.
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
While this fixed the Mixed Content errors, now I get this PHP Notice after using wp-cli:
PHP Notice: Undefined index: HTTP_X_FORWARDED_PROTO in phar:///opt/bitnami/apps/wordpress/bin/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1169) : eval()'d code on line 81
What should I do?
Share Improve this question asked Jul 23, 2019 at 13:10 paradroidparadroid 1952 silver badges13 bronze badges1 Answer
Reset to default 1Check if isset()
first. It will not always be set (that is what the undefined index is referring to):
I took this from user temuraru
$isSecure = false;
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$isSecure = true;
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
$isSecure = true;
}
$REQUEST_PROTOCOL = $isSecure ? 'https' : 'http';
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745302297a4621508.html
评论列表(0条)