gpt4 book ai didi

php - 我的 htaccess 文件无法加载 css

转载 作者:太空宇宙 更新时间:2023-11-03 23:26:46 24 4
gpt4 key购买 nike

我试图找到一些答案,但它对我不起作用,所以我决定在这里问:我是 codeigniter 的新手,在观看了一些教程后,我最终得到了这个 .htaccess 代码。

 <IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /myprojectname
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index.php|css|robots.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

我在本地主机上使用 xampp,我的问题是我无法在我的 View 中加载我的 css

 <link rel="stylesheet" href="css/metro-bootstrap.css">

实际上我在 RewriteCond $1 !^(index.php|css|robots.txt) 中包含了 css 根看起来像这样

/
-application
-css
-js
-font
-system
-.htaccess
-index.php

最佳答案

您不必在该行中包含 css 和 robots.txt,因为 RewriteCond %{REQUEST_FILENAME} !-f处理它(基本上它说如果它不是文件则重写 - '!-f' 部分),实际上你可以删除 RewriteCond $1 !^(index.php|css|robots.txt) .如果你的 css 仍然不起作用,请使用 <?php echo base_url();?>css/metro-bootstrap.css这行代码,base_url()表示元素中的基本路径。

关于php - 我的 htaccess 文件无法加载 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26654042/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com