Created
January 27, 2022 00:21
-
-
Save emrahoruc/cbbe8d33d8aa83b47715c7c63dcb20a4 to your computer and use it in GitHub Desktop.
Codeigniter 3.011 base_url detection
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 | |
# Source: https://codeigniter.com/userguide3/installation/upgrade_303.html | |
$config['base_url'] = ['domain1.tld', 'domain2.tld']; | |
if (in_array($_SERVER['HTTP_HOST'], $config['base_url'], true)) { | |
$domain = $_SERVER['HTTP_HOST']; | |
} else { | |
$domain = $config['base_url'][0]; | |
} | |
if (! empty($_SERVER['HTTPS'])) { | |
$config['base_url'] = 'https://'.$domain; | |
} else { | |
$config['base_url'] = 'http://'.$domain; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment