css文件无法加载codeigniter?

时间:2017-02-07 07:00:13

标签: css hyperlink

我在header.php上有这个链接我在stackoverflow中遵循了所有正确的答案,但它仍然没有为我工作。任何人都可以帮忙。谢谢你提前:))

我的文件夹结构是:

主文件夹: 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 

我的autoload.php

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

我的.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>

我的config.php

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

我的控制台错误

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

1 个答案:

答案 0 :(得分:1)

您需要为所有资产创建特殊文件夹。

如果你把它们放到应用程序文件夹中,你会因为CI中的.htaccess规则而有403错误。

我建议您在根结构中创建文件夹,例如'assets',并保留所有css / js。

所以你最终会走这条路

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

还要确保你有正确的.htaccess

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

试着让我知道。

相关问题