CodeIgniter multi base_url

As I wrote in a previous post the problem with defining the variable base_url is quite troublesome. In concreteness this variable takes care of creating a path to links, an action movie in the forms, redirektite and so on and if it's not setnata CI nereaboti korekno 🙂 Works but does some crazy things with url's 🙂 Decision, as always, is the clutter ( for me it pops up a bit before I decide to write it yourself) 😀

$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']);

With this piece of code is replaced in the config file base_url. Works as seen for both http and https. Takes only the folder in which you placed the platform so, you don't need any intervention on our part.

leave a reply

Your email address will not be published. Required fields are marked *

anti SPAM *