Skip to content

Instantly share code, notes, and snippets.

@madssj
Created February 27, 2015 13:57
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 madssj/142e5bcb714f9e162ae0 to your computer and use it in GitHub Desktop.
Save madssj/142e5bcb714f9e162ae0 to your computer and use it in GitHub Desktop.
A fix for running a wordpress with a new url, setting WP_HOME and WP_SITEURL to whatever is in $_SERVER['HTTP_HOST']
/** Automaticly set the correct WP_HOME and WP_SITEURL based on HTTP_HOST */
$absolute_url = "http" . ($_SERVER['HTTPS'] ? 's' : '') . "://{$_SERVER['HTTP_HOST']}";
if ($_SERVER['HTTP_PORT'] != 80 || $_SERVER['HTTP_PORT'] != 443) {
$absolute_url .= "{$_SERVER['HTTP_PORT']}";
}
define('WP_HOME', $absolute_url);
define('WP_SITEURL', $absolute_url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment