2011-07-14 28 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