Opencart产品ID到当前SEO链接


Opencart product ID to current SEO link

Im使用vqmod的ajax(实时搜索)。我已经启用了我的SEO和产品链接工作得很好。但当我通过搜索功能点击一个产品时,它会把我带到旧的链接,即:

index.php?route=product/product/&product_id=123

我当前的SEO链接看起来像这个

shop/Datorkomponenter/Chassi/Aerocool-DS-Cube-Devil-Red

我在.XML文件中搜索了Vqmod,发现了这段代码,也许它连接到了旧链接。

select: function(event, ui) {
   if(ui.item.value){
   location = 'index.php?route=product/product/&product_id='+ui.item.value;
     }else{
   $('.button-search').trigger('click');
     }
   return false;
}

有什么可以更改或修改的吗?也许从.htaccess重定向?

处理这一问题的可能方法是(按照降低需求的顺序):

  1. 返回带有ajax结果的seo-url
  2. 执行第二个ajax请求以获取seourl
  3. 加载产品页面后重定向

在所有这些场景中,您都希望使用核心Opencart url类,如下所示:

$url = $this->url->link('product/product', 'product_id=' . $product_id);

您可以使用以下.htaccess代码进行检查。

Options +FollowSymlinks
# Prevent Directoy listing 
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "(?i)(('.tpl|'.ini|'.log|(?<!robots)'.txt))">
 Order deny,allow
 Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/  
RewriteBase /yourshopfolder/
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^system/download/(.*) /index.php?route=error/not_found [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]

在根文件夹上创建自己的htaccess文件,并将上面的代码放在上面。它会起作用的。

我已经在2.0.2.0+

的开放式购物车版本中检查过了