I have a site where I have added the base_url() for calling the css and js files. The base_url() is without www. It is working fine with http://example.com but not working with http://www.example.com. That is it is showing some issues like not taking the fonts, sessions etc. I have searched many solutions but not able to find the right one.
Please tell me a solution.
You can do using .htacess redirect as @Arjar Aung provided.
I used this way at my config file
if(strpos($_SERVER['HTTP_HOST'],'www')===false)
{
$config['base_url'] = 'http://example.com';
}
else
{
$config['base_url'] = 'http://www.example.com';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With