mod_rewrite

时间:2015-08-05 11:52:37

标签: 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,它似乎仍在重写。

有关为什么会导致问题的任何建议?

1 个答案:

答案 0 :(得分:3)

您可以使用:

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

相关问题