Created
September 7, 2017 10:46
-
-
Save isu3ru/2c53f52f26ac09a030bc1f7f52d566d3 to your computer and use it in GitHub Desktop.
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 base_url() { | |
| $isSecure = false; | |
| if (isset($_SERVER['HTTPS'])) { | |
| $isSecure = $_SERVER['HTTPS'] == 'on'; | |
| } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { | |
| $isSecure = true; | |
| } | |
| $REQUEST_PROTOCOL = $isSecure ? 'https' : 'http'; | |
| return sprintf("%s://%s", $REQUEST_PROTOCOL, $_SERVER['HTTP_HOST']); | |
| } | |
| // echo base_url(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment