Posted By

traeregan on 10/05/10


Tagged

ci codeigniter baseurl Dynamic-baseurl


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

riddla
zreedeecom
tamala73


CodeIgniter Dynamic base_url


 / Published in: PHP
 

  1. // Determine Subdirectory of Install Path, If Any
  2. // If Not Present, Will Result in /
  3.  
  4. $slash = explode('/', getenv("SCRIPT_NAME"));
  5. $current_filename = $slash[count($slash) - 1];
  6. $host_url = str_replace($current_filename, "", getenv("SCRIPT_NAME"));
  7.  
  8. // If https being used, set base_url to https
  9.  
  10. $http_or_https = (!isset($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) != 'on') ? 'http' : 'https';
  11.  
  12. $config['base_url'] = $http_or_https ."://". $_SERVER['HTTP_HOST'].$host_url;

Report this snippet  

You need to login to post a comment.