CSS 和 javascript 未加载重写条件?
仅使用重写后规则
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>
Possible Duplicate:
Css and javascript Not Loading in rewrite rule
After using only rewrite rule
RewriteEngine On
RewriteRule ^profile.php$ profile.php
and when i load profile.php the css and javascript are loading
but when make a change in rule and add condition
RewriteEngine On
RewriteCond %{REQUEST_URI} !/profile.php$
RewriteRule ^profile.php$ profile.php
and then the js and css are not loading
Coding of profile.php is
<!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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为
RewriteCond
说:仅当 url 不仅包含 /profiles
时才应用以下RewriteRule,
您应该这样写:(
不带感叹号)
添加:
如果您不希望 mod_rewrite 规则应用于脚本和其他特定文件请求,您应该为它们编写规则。
例如
it's because the
RewriteCond
says :apply the following
RewriteRuleonly if the url doesn't only contain /profiles
you should write it like :
(without the exclamation mark)
in add:
If you don't want your mod_rewrite Rules to be apply on scripts and other specific files request, you should write a Rule for them.
E.g.