.htaccess重写,不影响相对图像/css/js url



我需要一些简单的帮助与我的htaccess文件,提前谢谢你。

我有一些网站网址,如:

  • www.site.com/index.php ? page_path = solutions-overview.html
  • www.site.com/index.php ? page_path = solutions-a.html

我想使用RewriteEngine将上述链接分别更改为以下链接:

  • www.site.com/solutions/overview
  • www.site.com/solutions/a
下面是我使用的。htaccess代码:
RewriteEngine On
RewriteRule ^solutions/overview index.php?page_path=solutions-overview.html
RewriteRule ^solutions/a index.php?page_path=solutions-a.html

这是有效的,但是我所有的图像,CSS文件和JS文件不再加载,因为页面试图获取错误的url。例如,"/images/blah.jpg"被加载为"/solutions/images/blah.jpg"。

如何修改htaccess代码以防止相对url发生变化?

谢谢!

<BASE href="http://www.yoursitename.com/">添加到您的页面<head>标签内,如下所示:

<head>
    <title>Your site title</title>
    <BASE href="http://www.yoursitename.com/">
    ....
</head>

最新更新