The project locally works fine $config[‘base_url’] = “localhost/”;
Codeigniter is getting the default controller welcome and login.php,
but login.php is not getting the resources from assets folder
all the get requests for a resource are not found. When I inspect I get errors
xGET example.com/assets/TEMPLATE/LoginPage/vendor/bootstrap/css/bootstrap.min.css
net::ERR_ABORTED 404
CodeIgniter folder structure in Cpanel public_html
+application
+assets
+system
index.php
.htaccess
I’ve configured the application/config/config.php
$config['base_url'] = 'www.mysite.com/';
$config['index_page'] = '';
I’ve configured the application/config/autoload.php
$autoload['packages'] = array('url');
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
the pages are loading resources:-
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/TEMPLATE/LoginPage/vendor/bootstrap/css/bootstrap.min.css">
2
Answers
Rather than using href=”
<?php echo base_url();?>
assets/TEMPLATE/LoginPage/vendor/bootstrap/css/bootstrap.min.css”> just use href=”/assets/TEMPLATE/LoginPage/vendor/bootstrap/css/bootstrap.min.css”>Also, add http:// or https:// to your base URL depending on your SSL status.
Try using link_tag from html helper.
First load html helper in controller, or make it autoload in config/autoload.php
Then try putting this in your header block of view file: