2

我需要一些关于我的 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 发生变化?

谢谢!

4

1 回答 1

4

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

<head>
    <title>Your site title</title>
    <BASE href="http://www.yoursitename.com/">
    ....
</head>
于 2016-02-03T08:52:55.167 回答