/index.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
/** * Define APP_URL Dynamically * Write this at the bottom of index.php * * Automatic base url */ $isSecure = false; if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $isSecure = true; } 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; } $protocol = $isSecure ? 'https' : 'http'; //var_dump($protocol); define('APP_URL', $protocol . "://{$_SERVER['SERVER_NAME']}".str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME'])); //echo $_SERVER['SCRIPT_NAME'];// /tf_web2/index.php //var_dump($_SERVER['HTTPS']); //exit(); |
/application/config/config.php
1 |
$config['base_url'] = APP_URL;//From index.php |