Reputation: 1265
i configure website on my local host using XAMPP but other rhan homepage the css files not loding
my .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
config.php
$config['index_page'] = '';
$config['base_url'] = 'http://hypertradeproject.local/';
on home page css link like.
<link rel="stylesheet" href="assets/css/bootstrap.css">
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
when i open page source they are like
and on all other pages they are like i.e
<link rel="stylesheet" href="assets/css/bootstrap.css">
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
when i open page source they are like
http://hypertradeproject.local/site/cat_one_subcat/assets/css/bootstrap.min.css http://hypertradeproject.local/login/assets/css/bootstrap.min.css
they have to be like
http://hypertradeproject.local/assets/css/bootstrap.min.css http://hypertradeproject.local/assets/css/bootstrap.min.css
im new to codeigniter. any suggestions.
thanks in advance.
Upvotes: 0
Views: 189
Reputation: 1265
Its working heres the two diffrent ways.
Either place base_url
(base url whic we defign in application/config/config.php
) at the start in href
like this.
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/bootstrap.css">
or just add "/"
start of href
like this.
<link rel="stylesheet" href="/assets/css/bootstrap.css">
Upvotes: 0
Reputation: 2681
$config['root_dir']= "/"; Add this line in your application/config/config.php file
then inlcude your css file like this
<link rel="stylesheet" href="<?php echo $this->config->item('root_dir')?>assets/css/bootstrap.css">
<link rel="stylesheet" href="<?php echo $this->config->item('root_dir')?>assets/css/bootstrap.min.css">
Upvotes: 1
Reputation: 6994
First load url
helper in application/config/autoload.php
using
$autoload['helper'] = array('url');
OR you can load url
helper in controller
using $this->load->helper('url');
then link your css files like below:
<link rel="stylesheet" href="<?php echo base_url('assets/css/bootstrap.css');?>">
<link rel="stylesheet" href="<?php echo base_url('assets/css/bootstrap.min.css');?>">
Upvotes: 1