2013-05-20 59 views
0

我剛剛開始使用codeigniter,而且我很難理解爲什麼瀏覽器無法呈現或加載js文件和css文件。我在嘗試加載css時收到404錯誤

裏面我認爲我成功地使源

<title></title> 
    <script src="/Scripts/jquery-1.7.1.js"></script> 

而且使用FTP客戶端,我注意到,有腳本/上的public_html文件夾jQuery的1.7.1.js文件。

當我嘗試從瀏覽器手動檢索該js時,我得到404錯誤。

我的.htaccess文件內容

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

回答

1

將您的重寫條件更改爲下面提到的,

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

在我們重新撰寫http://domainName.com/home的所有URL到http://domainName.com/index.php/home,但並不包括具有在那裏URL請求URI圖像,腳本,CSS,robots.txt的,因此上述規則通過在添加的RewriteCond腳本,我們繞過http://domainName.com/Script的所有網址去codeigniter index.php

2

你的htaccess說路由什麼,但下面的index.php/$ 1:

RewriteCond $1 !^(index\.php|images|robots\.txt) 

所以只需添加腳本和CSS目錄的發言:

RewriteCond $1 !^(index\.php|Scripts|css|images|robots\.txt) 
相關問題