lets we check how to manage and set the base URL in CodeIgniter.

Greetings from the codeziper team, in this post we will explain in brief how to set the base_url() path in CodeIgniter.

here we have shared the code which you need to set in the config.php

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

 

You can also set the base URL in the constant file

defined('BASE_URL') OR define('BASE_URL', (is_https() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . '/');

after you can use this constant variable in the config file shown below:

$config['base_url'] = BASE_URL;

Where is the base URL in CodeIgniter?

base URL managed from config.php file,config.php file is located and configured in your CodeIgniter project of, application/ config/ config.php directory.

 

Thanks, Regards,

Codeziper and Team.




Leave a reply related to this blog

Tell us about your idea, and we’ll make it happen.

Have a brand problem that needs to be solved? We’d love to hear about it!
Let’s Get Started
up