2014-10-30 97 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()表示项目中的基本路径。