Skip to content

Instantly share code, notes, and snippets.

@vastus
Created October 22, 2018 11:54
Show Gist options
  • Save vastus/46b9c26ddc77302a5f9ce7bdf9b5b123 to your computer and use it in GitHub Desktop.
Save vastus/46b9c26ddc77302a5f9ce7bdf9b5b123 to your computer and use it in GitHub Desktop.
<?php
/*
* Getting too many redirects when SSL is not on and the WP_HOME and
* WP_SITEURL settings are set.
*
* These settings should work with CloudFront and a WP instance.
*/
$protocol = (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) ? $_SERVER['HTTP_X_FORWARDED_PROTO'] : 'http';
$host = $_SERVER['HTTP_HOST'];
$origin = $protocol . '://' . $host;
if ($protocol == 'https') {
$_SERVER['HTTPS'] = 'on';
}
define('WP_HOME', $origin);
define('WP_SITEURL', $origin);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment