Posted By

DrewDouglass on 07/11/09


Tagged

php codeigniter


Versions (?)

Who likes this?

14 people have marked this snippet as a favorite

vali29
jealousy
GandalfGrey
AzizLight
alejandrosuch
mhulse
dantreacy
jatap
marceloabelda
qubestream
ljayz
prit
cindreta
Priestd09


CodeIgniter Automatic Base URL Configuration


 / Published in: PHP
 

URL: http://codeigniter.com/wiki/Automatic_configbase_url/

More info found in the link above, basically, you can replace the $config['base_url'] to the snippet below and you no longer need to set the base url. Useful for making your application more portable.

  1. $config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
  2. $config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
  3. $config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: montanaflynn on July 13, 2009

excellent.

You need to login to post a comment.