0

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

http://hypertradeproject.local/assets/css/bootstrap.css

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.

4 Answers 4

1

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');?>">
Sign up to request clarification or add additional context in comments.

Comments

1

$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">

Comments

1

You can simply add site_url in front of path.

Thanks

1 Comment

you are absolutely right .or add "/" in front of path.
0

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">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.