Skip to content

Instantly share code, notes, and snippets.

@VirtuBox
Created August 5, 2019 02:35
Show Gist options
  • Save VirtuBox/0d18a25aa9886df40771e8b8a83931d6 to your computer and use it in GitHub Desktop.
Save VirtuBox/0d18a25aa9886df40771e8b8a83931d6 to your computer and use it in GitHub Desktop.
set wordpress siteurl/home variable depending on HTTP_HOST
# source : https://github.com/pantheon-systems/WordPress/blob/default/wp-config.php
# license : GPL
# b2 is (c) 2001, 2002 Michel Valdrighi - m@tidakada.com -
if (isset($_SERVER['HTTP_HOST'])) {
// HTTP is still the default scheme for now.
$scheme = 'http';
// If we have detected that the end use is HTTPS, make sure we pass that
// through here, so <img> tags and the like don't generate mixed-mode
// content warnings.
if (isset($_SERVER['HTTP_USER_AGENT_HTTPS']) && $_SERVER['HTTP_USER_AGENT_HTTPS'] == 'ON') {
$scheme = 'https';
$_SERVER['HTTPS'] = 'on';
}
define('WP_HOME', $scheme . '://' . $_SERVER['HTTP_HOST']);
define('WP_SITEURL', $scheme . '://' . $_SERVER['HTTP_HOST']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment