base_url ?You will not get any Impotency error to set this and proceed. You can continue without setting, but you should know about HTTP header injection
You will get http://[::1]/ instead of your actual URL.
http://[::1]/ ??This is temporary URL which set by CI by Default. This will point the root of your document.
::1 - Server address (localhost) Read More about this
base_url()??Base URL should always point to root of your project folder. (outside application folder)
$config['base_url'] = 'http://localhost/path/to/project'; # If localhost
$config['base_url'] = 'http://stackoverflow.com/'; # If live
$config['base_url'] = 'http://stackoverflow.com/documentation'; # If live & inside subdomain (assume documentation is subfolder/subdomain)
base_url()??Most common use is to find the right path to your js or css files.
<link rel="stylesheet" href="/?originalUrl=https%3A%2F%2Friptutorial.com%2F%26quot%3B%26lt%3B%3Fphp%2520echo%2520base_url("styles/style.css');?>" />
<script src="/?originalUrl=https%3A%2F%2Friptutorial.com%2F%26quot%3B%26lt%3B%3Fphp%2520echo%2520base_url("vendor/jquery/jquery.min.js');?>"></script>
Adding the code above in your view will produce HTML as below:
<link rel="stylesheet" href="/?originalUrl=https%3A%2F%2Friptutorial.com%2F%26quot%3Bhttp%3A%2F%2Flocalhost%2Fpath%2Fto%2Fproject%2Fstyles%2Fstyle.css%26quot%3B%2520%2F%26gt%3B%26lt%3Bscript%2520src%3D%26quot%3Bhttp%3A%2F%2Flocalhost%2Fpath%2Fto%2Fproject%2Fvendor%2Fjquery%2Fjquery.min.js%26quot%3B%26gt%3B%26lt%3B%2Fscript%26gt%3B%253C%2Fcode">
Links