Mod rewrite Css和javascript未在重写条件下加载?
可能重复:Mod rewrite Css和javascript未在重写条件下加载?,mod-rewrite,Mod Rewrite,可能重复: 仅使用重写规则后 RewriteEngine On RewriteRule ^profile.php$ profile.php 当我加载profile.php时,css和javascript正在加载 但当在规则中进行更改并添加条件时 RewriteEngine On RewriteCond %{REQUEST_URI} !/profile.php$ RewriteRule ^profile.php$ profile.php 然后js和css就不会加载了 profile.ph
仅使用重写规则后
RewriteEngine On
RewriteRule ^profile.php$ profile.php
当我加载profile.php时,css和javascript正在加载
但当在规则中进行更改并添加条件时
RewriteEngine On
RewriteCond %{REQUEST_URI} !/profile.php$
RewriteRule ^profile.php$ profile.php
然后js和css就不会加载了
profile.php的编码是
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-…
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" href="http://localhost/css/profile.css" />
</head>
<body>
<table><tr><td><div class="image"><ul><li>My</li></ul></div>
</td></tr></table>
</body></html>
这是因为RewriteCond
说明:仅当url不包含/profiles
你应该这样写:
RewriteCond %{REQUEST_URI} /profile.php$
(不带感叹号)
加上:
如果您不希望您的mod_重写规则应用于脚本和其他特定文件请求,您应该为它们编写一个规则
例如
+1但最好使用忽略现有文件重写的条件,例如,RewriteCond%{REQUEST_FILENAME}-f
@Jimmy很好,我正在做测试(请求文件的内容可用吗?如果不请求,则找不到页面的内容)。我从来没有使用过这个指令,事实证明这是一个很好的选择。请不要重复本质上相同的问题。如果要添加任何新内容,请更新原始内容。谢谢
RewriteRule \.(css|jpe?g|gif|png)$ - [L]