Auto-Determine Subdirectory of Install Path, If Any


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // Auto-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. // e.g. usage
  9.  
  10. $config['base_url'] = "http://". $_SERVER['HTTP_HOST'].$host_url;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.