How to access static assets in CodeIgniter?
Make the structure something like this
root (is your root directory) /application /system /static /images /css /js
Change your base URL in config.php
/* |-------------------------------------------------------------------------- | Base Site URL |-------------------------------------------------------------------------- | | URL to your CodeIgniter root. Typically this will be your base URL, | WITH a trailing slash: | | http://example.com/ | | If this is not set then CodeIgniter will guess the protocol, domain and | path to your installation. | */ // use this if your project is in root$config['base_url'] = 'http://example.com/';// use this if your project is in folder/subfolders//$config['base_url'] = 'http://example.com/newproject/liveproject/';
Autoload URL
helper in autoload.php
/* | ------------------------------------------------------------------- | Auto-load Helper Files | ------------------------------------------------------------------- | Prototype: | | $autoload['helper'] = array('url', 'file'); */$autoload['helper'] = array('url');
In your view file
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>static/style.css" /><img src="<?php echo base_url(); ?>static/images/myimage.jpg" alt="" />
Hope this helps. Thanks!!