我正在使用安装在/ products子目录中的OpenCart 1.5.4。我在根目录中安装了一个wordpress站点。我对它们进行了相同的处理,因此它看起来像是同一个网站。
我想重写Home链接的所有实例(特别是面包屑)到我的根目录(而不是我的OC安装所在的子目录(/ products))。
从一些研究中我了解到,最好的方法是在HTACCESS文件中。我对操作htaccess文件非常不熟悉。标准的htaccess文件具有以下重写规则:
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
如何添加规则以更改主页链接:
www.myurl.com/products/index.php?route=common/home
为:
www.myurl.com /
最后,在当前安装中,此文件名为.htaccess.txt。我是否必须从服务器删除此文件,删除.txt,并上传名为.htaccess的文件以使其正常工作?
答案 0 :(得分:0)
要删除index.php?route=common/home
,请按照guide here进行操作。至于.htaccess代码,您需要将其上传到opencart安装目录并从名称中删除.txt
以使其成为.htaccess
答案 1 :(得分:0)
您不能对Wordpress和OpenCart使用http://www.myurl.com/
网址,因为它们都使用index.php文件。有一个可以用来使事情看起来更好的工作:
您的网站根文件夹中需要.htaccess
个文件,并在该.htaccess
文件中添加以下行:
RewriteEngine On
RewriteRule ^cart.php?route=([a-zA-Z0-9_-]+)$ products/index.php?route=$1
这样可以通过网址http://www.myurl.com/cart.php?route=common/home
代替www.myurl.com/products/index.php?route=common/home
答案 2 :(得分:0)
你的设置就像我的设置一样,就像这样......
我有一个类似Jay Gilford在他的回答中提到的mod。
所以我的OC链接是
而不是
http://mysite.loc/store/index.php?route=common/home
通过此设置,您仍可以从任何商店链接的痕迹路径中找到主页链接。与Home > Category > Product
就我而言,我所做的是,我已将主页文字重命名为商店文字。并从OC菜单中删除了主页链接菜单。这很简单,但我觉得很实用。
然后我添加了主页链接到痕迹路径和我的OC菜单。所以我的面包屑痕迹就是这样......
Home > Store> Category > Product
主页链接被硬编码到包含面包屑的每个.tpl页面。就像catalog/view/theme/default/template/product/product.tpl
一样。您可以通过将面包屑放在标题中来进一步修改它。
在我的情况下,我已将其硬编码到我的身上
catalog/view/theme/default/template/product/product.tpl
和其他相关.tpl
个文件
<div class="breadcrumb">
<a href="/">Home</span></a>»
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
<?php } ?>
</div>
我通过这样做重命名原来的Home
链接;
changed
$_['text_home'] = 'Home';
to
$_['text_home'] = 'Store';//Or whatever you like
from the file. catalog/language/english.php - in my case.
我知道这是几个月前被问到的,只是为未来的读者发布这个