【问题标题】:codeigniter2 not able to load css with index.php urlcodeigniter2 无法使用 index.php url 加载 css
【发布时间】:2014-01-12 14:04:19
【问题描述】:

我创建了一个资产文件夹,并在其中创建了一个 css 文件夹。为了访问 css 文件,我这样做:

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

只要网址是,100% 可以正常工作:

http://localhost/web/

但是当我将 URL 更改为

http://localhost/web/index.php 或者

http://localhost/web/index.php/welcome/

它停止加载 css 或图像。必须注意的是,css 位于 assets 文件夹中,其位置为:localhost/web/assets/,其中图像与 php 文件一起位于 view 文件夹中。

我的 .htaccess 文件如下所示

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

加上我的 .htaccess 文件在应用程序文件夹中

【问题讨论】:

  • 您在 config.php 中设置了什么 base_url?如果您使用 Firebug 等工具查看页面,它试图从哪个 URL 加载 CSS 文件?

标签: php codeigniter codeigniter-2 coda


【解决方案1】:

尝试添加重写条件以排除图像和资产目录:

RewriteCond %{REQUEST_URI} !(images|assets) [NC]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-03
    • 2013-11-08
    • 2011-04-19
    • 1970-01-01
    相关资源
    最近更新 更多