Set up the base url in codeigniter
In Config.php
$config['base_url'] = 'http://localhost/Appsite/website/';
$config['index_page'] = '';
# If online site
# $config['base_url'] = 'http://stackoverflow.com/';
In .htaccess
(outside application folder) - To remove index.php
in URL
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
To accessing URL
<a href="<?php echo base_url();?>contollerName/methodName"> click here</a>
To access image
<img src="<?php echo base_url();?>images/images.PNG”>
To access CSS
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/style.css"/>
To use base_url
load URL helper from autoload.php
In your config.php
set the base_url()
as,
$config['base_url'] = 'http://localhost/projectname/';
In your view load the image as,
<img src="<?php echo base_url();?>images/images.PNG”>