Genina Anne Gabuten
Genina Anne Gabuten

Reputation: 278

css file cant load in codeigniter?

I have this link on my header.php I followed all the correct answers here in stackoverflow and still it didnt work for me. Can anyone help pls. Thankyou in advance :)

my folder structure is:

main folder: ci_attl - application - css - style.css

<link href="<?php echo base_url();?>application/css/style.css" rel="stylesheet">  - not working 

<link href="<?php echo base_url();?>/css/style.css" rel="stylesheet">  - not working 

<link href="<?php echo base_url();?>../css/style.css" rel="stylesheet">  - not working 

my autoload.php

$autoload['helper'] = array('form','url', 'html');

my .htaccess

<IfModule mod_rewrite.c>

  RewriteEngine On
  RewriteBase /ci_attl/

  RewriteCond %{REQUEST_URI} ^system.*
  RewriteRule ^(.*)$ /index.php?/$1 [L]

  RewriteCond %{REQUEST_URI} ^application.*
  RewriteRule ^(.*)$ /index.php?/$1 [L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]    

</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>

my config.php

$config['base_url'] = '';
$config['index_page'] = '';

my console error

Failed to load resource: the server responded with a status of 403 (Forbidden) 
http://[::1]/ci_attl/application/css/style.css

Upvotes: 0

Views: 770

Answers (1)

pr0metheus
pr0metheus

Reputation: 488

You need to create special folder for all of your assets.

If you put them into application folder you will have 403 error because of .htaccess rules in CI.

I suggest you to create folder in your root structure for example 'assets' and keep all css/js in there.

So you will end up with this path

http://[::1]/ci_attl/assets/css/style.css

Also make sure that you have correct .htaccess

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /ci_attl/
RewriteCond $1 !^(index\.php|assets|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Try and let me know.

Upvotes: 1

Related Questions