php - mod_rewrite 后样式表未加载

标签 php css apache .htaccess mod-rewrite

我目前正在使用 mod_rewrite 为我的网页开发语言功能。我可以输入带有语言选项的 URL,并使用 $_GET 在我的 php 索引文件中提取该信息。但由于某种原因,我的 CSS 文件无法再加载。

这是我的 .htaccess 代码:

RewriteEngine On

RewriteBase /books/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(se|en)/(.*)$ index.php?url=$2&language=$1 [QSA,L]
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

我的样式表链接如下:

     <link rel="stylesheet" type="text/css" href="localhost/books/css/style.css">

如果我尝试在浏览器中查找 CSS 文件,即使我设置了 RewriteCond,它似乎仍在重写。

关于为什么这会导致问题有什么建议吗?

最佳答案

您可以使用:

RewriteEngine On

RewriteBase /books/

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]

RewriteRule ^(se|en)/(.*)$ index.php?url=$2&language=$1 [QSA,L]
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

因为 RewriteCond 仅适用于之后的第一个 RewriteRule

关于php - mod_rewrite 后样式表未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31831753/

相关文章:

javascript - 全宽固定高度内容 slider

apache - 我的 MediaWiki 网站不会将样式表作为文本/CSS 提供

php - 无法从 $this->db->last_query(); 得到结果;代码点火器

php - PHP 中的命名空间语句可以是 "included"吗?

html - 尝试居中对齐图像

jquery - 使用 jQuery 在悬停时交换 DIV 类

php - 使用 PHP SSH 连接到多个 pi

apache - htaccess mod_rewrite 主机名

php - 加密和解密字符串 - PHP

PHP 文件作为 URL 失败视频流