2014-10-30 136 views
0

我試圖找到一些答案,但它不適用於我,所以我決定在這裏問: 即時通訊新Codeigniter,看完一些教程後,我結束了這個.htaccess碼。我的htaccess文件無法加載css

<IfModule mod_rewrite.c> 
     RewriteEngine On 

    RewriteBase /myprojectname 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond $1 !^(index.php|css|robots.txt) 
    RewriteRule ^(.*)$ index.php/$1 [L] 

</IfModule> 

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

IM使用本地主機上的XAMPP,我的問題是,我不能加載我的CSS在我看來

<link rel="stylesheet" href="css/metro-bootstrap.css"> 

的時候,其實我包括CSS在RewriteCond $1 !^(index.php|css|robots.txt) 根看起來像這樣

/ 
-application 
-css 
-js 
-font 
-system 
-.htaccess 
-index.php 
+0

'RewriteCond%{REQUEST_FILENAME}!-f'應該已經確保現有文件不被重寫。嘗試刪除排除index.php,css和robots.txt的行。 – Jerodev 2014-10-30 13:18:51

+1

需要刪除'RewriteCond $ 1'行。 – 2014-10-30 13:25:36

+0

事實上,'RewriteCond'根本沒有意義... – CBroe 2014-10-30 13:27:17

回答

2

您不必在該行中包含css和robots.txt,因爲RewriteCond %{REQUEST_FILENAME} !-f會照顧它(基本上它說如果它不是文件 - '!-f'部分就表示重寫) ,實際上你可以刪除RewriteCond $1 !^(index.php|css|robots.txt)。如果你的css仍然無法工作,請使用<?php echo base_url();?>css/metro-bootstrap.css這行代碼,base_url()表示項目中的基本路徑。