php - codeigniter 中的 Assets

标签 php codeigniter

我刚开始使用 codeigniter,想在我的 View 中包含一些外部 CSS。这是我的目录结构:

application
   ....
system
   ....
assets
    css
        style.css

我正在使用此 html 代码链接文件:(以 example.com 为例,大声笑)

<link rel="Stylesheet" type="text/css" href="http://example.com/assets/css/style.css"/>

这是我的 .htaccess 文件:

RewriteEngine on

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

现在,我的问题是它返回 404 错误。如果您需要更多信息,请说出来。

提前致谢!

最佳答案

我发现 CI .htaccess 规则对必须添加所需的所有不同文件夹有一些限制。因此,我使用以下内容:

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

试一试,看看进展如何。

关于php - codeigniter 中的 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6693182/

相关文章:

php - 在 Laravel 5.1 中使用 Entrust 中间件时出现异常

php - Yii2 登录后重定向到上一页

codeigniter - 在 codeigniter 中打印列数(*)

php - Codeigniter,插入 ID

php - 如何在 PHP 对象中添加键值? (代码点火器)

php - 从对 PHP 脚本的 ajax 调用获取 JSON 响应

javascript - 文件更改时刷新页面

php - MySQL 查询行,3 个最高值?

php - codeigniter 在本地 xampp 上工作正常,但在所有自定义 Controller 的 apache Web 服务器上工作 404

php - 如何对 foreach 内标题的 $item 值进行排序