Reputation: 6449
I have just uploaded my website to the webhost and I realised the base_url()
contains the value of the constant FCPATH
, that points to the local root path
So, instead of printing http://mywebsite.com/ It prints something like http://mywebsite.com/var/www/html/.../
This is a linux host and it is printing the disc path to the root folder.
It works. It is generating a valid URL to the files (http://mywebsite.com/var/www/html/.../js/my.js is routed to the correct file)
But I was using that public url for other purposes on my website. Do you know what is going on? is that a normal behavior? Is there any other function or constant that I can use or do I have to subtract FCPATH from base_url()
Upvotes: 0
Views: 727
Reputation: 3101
Use this in your config file:
$config['base_url'] = "http://". $_SERVER['HTTP_HOST'] . preg_replace('@/+$@','', dirname($_SERVER['SCRIPT_NAME']));
Upvotes: 1