2017-02-07 136 views
0

我在我的header.php上有这个链接我在这里在stackoverflow中跟着所有正确的答案,仍然没有为我工作。任何人都可以帮助请求。三江源提前:)css文件不能在codeigniter中加载?

我的文件夹结构是:

主文件夹: ci_attl - 应用 - 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 
+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] 

尝试,让我知道。

+0

ow现在它的工作谢谢pr0metheus :) –

+0

现在我有页眉页脚文件分开:)谢谢你 –