molnard molnard - 3 months ago 10
PHP Question

CodeIgniter - css file doesn't work

I have problem with css file in CodeIgniter framework. In my autoconfig file I load url and html helper. In view I have code:

<?php echo link_tag('application/assets/css/style.css')?>


but this code doesn't work. In config file my base_url is
http://localhost/CI
. My directory structure is

-application
-assets
-css
-views
-partials
-home
I try

<link rel="stylesheet" type="text/css" href="<?=base_url()?>application/assets/css/style.css"/>


or

<link rel="stylesheet" type="text/css" href="<? echo base_url('application/assets/css/style.css')?>"/>


but this also doesn't work.

Answer

Put your asset folder in project root, out side application folder.

Change the link to,

<?php echo link_tag('assets/css/style.css')?>

CI Folder Structure

enter image description here

Comments