Skip to content

Instantly share code, notes, and snippets.

@tylerhall
Created December 1, 2019 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerhall/375ad1ac76dedbab2a719a6b4c845fda to your computer and use it in GitHub Desktop.
Save tylerhall/375ad1ac76dedbab2a719a6b4c845fda to your computer and use it in GitHub Desktop.
<?php
if(isset($_SERVER['HTTP_X_ORIGINAL_HOST'])) {
$proto = empty($_SERVER['HTTP_X_FORWARDED_PROTO']) ? 'http' : (($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ? 'https' : 'http');
$url = $proto . '://' . $_SERVER['HTTP_X_ORIGINAL_HOST'];
if($proto == 'https') { $_SERVER['HTTPS'] = 'on'; }
} else {
$s = empty($_SERVER['HTTPS']) ? '' : ($_SERVER['HTTPS'] == 'on') ? 's' : '';
$port = ($_SERVER['SERVER_PORT'] == '80') ? '' : (":".$_SERVER['SERVER_PORT']);
$url = "http$s://" . $_SERVER['HTTP_HOST'] . $port;
}
define('WP_HOME', $url);
define('WP_SITEURL', $url);
unset($s, $port, $url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment