当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Codeigniter: File not found

问题描述:

Why do the paths to my css,js and img files have the CONTROLLER name BEFORE 'application'?

Path from firebug:

localhost/quote-generator/admin/application/assets/bootstrap/css/bootstrap.min.css

My code:

<link rel="stylesheet" type="text/css" href="<?php echo base_url('assets/bootstrap/css/bootstrap.min.css'); ?>" >

This is from a header.php file i have included in one of my views generated in my Admin controller in the 'login' function.

Any suggestions??

网友答案:

Its bad practise to keep assets files, i.e. css/images in the application folder

Your Codeigniter folder structure should be this

root
  |
  |_______________application
  |_______________assets
                   |_________css
                   |_________images

considering the root is the admin

setting the above structure, set the base_url like this

$config['base_url'] = 'localhost/quote-generator/admin/';

then put the href like this

href="<?php echo base_url();?>assets/bootstrap/css/bootstrap.min.css"
网友答案:

use :

site_url()

instead of

base_url

it's saver that way

分享给朋友:
您可能感兴趣的文章:
随机阅读: