2011-07-14 36 views
3

我刚开始使用codeigniter,并希望在我的视图中包含一些外部css。这是我的目录结构:codeigniter中的资产

application 
    .... 
system 
    .... 
assets 
    css 
     style.css 

我使用这个HTML代码链接的文件:(使用example.com作为一个例子,笑)

<link rel="Stylesheet" type="text/css" href="http://example.com/assets/css/style.css"/> 

这里是我的.htaccess文件:

RewriteEngine on 

RewriteCond $1 !^(index\.php|images|css|js|robots\.txt) 
RewriteRule ^(.*)$ index.php/$1 [L] 

现在,我的问题是,它返回一个404错误。说如果你需要更多的信息。

在此先感谢!

回答

6

我发现CI .htaccess规则限制了必须添加所需的所有不同文件夹。因此,我使用以下内容:

# Checks to see if the user is attempting to access a valid file, 
# such as an image or css document, if this isn't true it sends the 
# request to index.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

给一个bash,看看你如何继续。

+0

哇,谢谢!它效果很好!感谢m8! – Fredefl