[Ilugc] [Ilug-C] Doubt in Code-Igniter [php]

  • From: rkrajeshkumar87@xxxxxxxxx (Rajesh kumar)
  • Date: Tue, 11 Mar 2014 08:49:13 +0530

Base URL is defined in application/config/config.php. Why do you want

 >> to change it? From version 2.1 onwards it's auto detected and that
should work well.
That said, here's the base_url I use in my applications and it is
portable to any hostname without fiddling with config files.
$config['base_url']     = ((isset($_SERVER['HTTPS']) &&
$_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .=

str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);


 This is the right method Or try the below.

$root = "http://".$_SERVER['HTTP_HOST'];
$root .=
str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

$config['base_url']    = "$root";

If CSS or JS or not loading please do check firebug for the url getting
loaded for the files.

say for examples, if css and js are present in $CI_root/includes/css and
$CI_root/includes/js then the url construct for them will be like below.

<link src="<?php echo base_url() ?>"includes/css/style.css" />

--
regards
Rajesh Kumar

Other related posts: