2011-10-25 80 views
0

我在我的笨應用程序的根稱爲/css它包含文件style.css目錄。當我使用href="<?php echo base_url();?>css/styles.css"鏈接到文件時,我的css無法運行,顯示爲html。笨CSS htaccess的,無法讀取文件

我已經在我需要修改我的.htaccess文件,以做到這一點的淨讀取,很多文章已經介紹瞭如何但是這些方法只是還沒有爲我工作。

如何,使用下面的代碼htaccess的,我可以啓用以下文件夾/圖像/ JS的閱讀,/ CSS。

我使用codeigniters默認htaccess的代碼去除的index.php

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

    #Removes access to the system folder by users. 
    #Additionally this will allow you to create a System.php controller, 
    #previously this would not have been possible. 
    #'system' can be replaced if you have renamed your system folder. 
    RewriteCond %{REQUEST_URI} ^system.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    #When your application folder isn't in the system folder 
    #This snippet prevents user access to the application folder 
    #Submitted by: Fabdrol 
    #Rename 'application' to your applications folder name. 
    RewriteCond %{REQUEST_URI} ^application.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    #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] 

</IfModule> 

<IfModule !mod_rewrite.c> 
    # If we don't have mod_rewrite installed, all 404's 
    # can be sent to index.php, and everything works as normal. 
    # Submitted by: ElliotHaughin 

    ErrorDocument 404 /index.php 
</IfModule> 
+0

恩,嗯,我沒有真正跟着你:這是預期的行爲。如果直接鏈接到樣式表,您會看到樣式表。你還想做什麼? –

+0

我可以看到樣式表,但某些原因Codeigniter不會將它讀爲css並將html添加到頂部。 – hairynuggets

+0

你的意思是: #blockthing {bunchof:css;}? –

回答

1

試試這個它的工作。

<link rel="stylesheet" href="<?php echo base_url();?>css/style.css" type="text/css" />