I know how to redirect non-www to www using the .htaccess. But for some reason, I can't do it from the .htaccess file! I would like to do this from application/config.php. There already have HTTP to https redirect. here is the code,
$root = (isset($_SERVER['HTTPS']) ? "https://" : "http://") . $_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;
Now, Is it possible to redirect non-www to www from here? If it's possible then how?
Thanks in advance.