重写多个变量的规则更改脚本src路径


Rewrite rule on multiple variables changing script src Path

我正在为我的网站使用"重写"规则,但其不断变化的脚本src Path

这是我使用的规则

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www'.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ /user_page.php?id=$1 [NC]
# Changing Search URL
RewriteRule ^/([^/]*)/([^/]*)/([^/]*)$ search_out.php?comp_city=$1&one=$2comp_landmark=$3 [L]

#更改搜索URL是导致问题的原因之一。。。它将向u显示指向的脚本src或所有链接rel="stylesheet"type="text/css"http://www.xxxxx.com/Rajpura/Schools/js/jquery-1.6.2.min.js而不是http://www.xxxxx.com/js/jquery-1.6.2.min.js

请帮助

您可以在每个页面的head标签中添加基本标签:

<base href="/">

这样,浏览器将在该页面中的所有链接前面加上/。

有关基本标记的更多信息,请参阅文档

在html中嵌入CSS或图像时,请尝试以斜杠开头,从根目录获取文件:

<link rel="stylesheet" href="/css/style.css" />

图像相同:

<img src="/images/pic.png" alt="image" />
<img src="/mypic.png" alt="image" />

或者一个变通办法是在你的模板中添加这个:

<base href="/">

这将强制浏览器在所有相关资源链接之前加上/(在本例中)。