Opencart SEF 破坏相关链接
Opencart SEF ruins relative links
我的 Opencart 网站在 SEF 模式下无法加载文件,并且类别名称在 url 中。
例如当我在这个 URL :
http://thehouseofmarley.ir/speaker/nikon-d300
本页亲戚URL:
image/globe.png
应该这样编译:
http://thehouseofmarley.ir/image/globe.png
但是浏览器无法加载它,因为它是这样编译的:
http://thehouseofmarley.ir/speaker/image/globe.png
我的 htaccess 文件未经编辑,等于 Github 版本:
https://github.com/opencart/opencart/blob/master/upload/.htaccess.txt
有人知道解决方案吗?
好的,现在您已经遇到了人们在切换到漂亮的 URL 方案时面临的最常见问题。解决方案也很简单,只需在 css、js、图像文件中使用绝对路径而不是相对路径。这意味着您必须确保这些文件的路径以 http://
或斜杠 /
.
开头
否则您可以将其添加到页面 HTML 的 <head>
部分下方:<base href="/" />
这样每个 relative URL 是从那个基础 URL 解析的,而不是从当前页面的 URL.
我的 Opencart 网站在 SEF 模式下无法加载文件,并且类别名称在 url 中。 例如当我在这个 URL :
http://thehouseofmarley.ir/speaker/nikon-d300
本页亲戚URL:
image/globe.png
应该这样编译:
http://thehouseofmarley.ir/image/globe.png
但是浏览器无法加载它,因为它是这样编译的:
http://thehouseofmarley.ir/speaker/image/globe.png
我的 htaccess 文件未经编辑,等于 Github 版本:
https://github.com/opencart/opencart/blob/master/upload/.htaccess.txt
有人知道解决方案吗?
好的,现在您已经遇到了人们在切换到漂亮的 URL 方案时面临的最常见问题。解决方案也很简单,只需在 css、js、图像文件中使用绝对路径而不是相对路径。这意味着您必须确保这些文件的路径以 http://
或斜杠 /
.
否则您可以将其添加到页面 HTML 的 <head>
部分下方:<base href="/" />
这样每个 relative URL 是从那个基础 URL 解析的,而不是从当前页面的 URL.