Skip to content

Instantly share code, notes, and snippets.

@halles
Created May 8, 2014 02:17
Show Gist options
  • Save halles/0f5f4fc1c1c0c21c54dc to your computer and use it in GitHub Desktop.
Save halles/0f5f4fc1c1c0c21c54dc to your computer and use it in GitHub Desktop.
Autoconfig site url in wp-config.php
<?php
if(!isset($_SERVER['HTTPS'])){
$port = 80;
$protocol = 'http';
}else{
$port = 443;
$protocol = 'https';
}
$port = ($port == $_SERVER['SERVER_PORT'])?'':':'.$_SERVER['SERVER_PORT'];
define('WP_SITEURL', $protocol.'://'.$_SERVER['SERVER_NAME'].$port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment