gpt4 book ai didi

php - mod_rewrite 后样式表未加载

转载 作者:行者123 更新时间:2023-11-28 11:07:03 26 4
gpt4 key购买 nike

我目前正在使用 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/

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