我刚开始使用 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/