Created
October 13, 2011 11:54
-
-
Save ChrisMcKee/1284052 to your computer and use it in GitHub Desktop.
Get site url with current protocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function siteURL() | |
{ | |
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; | |
$domainName = $_SERVER['HTTP_HOST'].'/'; | |
return $protocol.$domainName; | |
} | |
define( 'SITE_URL', siteURL() ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment