2017-02-24 44 views
0

如何在产品网址的末尾添加扩展名'.html'。
-My当前产品链接:
www.mysite.com/productlink
-I想成为:
www.mysite.com/productlink.htmlOpencart 1.5x - 在产品网址的末尾添加'.html'

我编辑目录/控制器/通用/ seo_url。 PHP,产品网址现在有.html,但是当我点击一个链接,它说404没有找到。我需要做什么 ?

if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id') || ($data['route'] == 'news/article' && $key == 'news_id')) { 
       $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "'"); 

if ($query->num_rows) { 
    $url .= '/' . $query->row['keyword'] . '.html';      
    unset($data[$key]); 
}  

回答

0

您可以通过使用的.htaccess 试试这个做到这一点:我没有测试此所以它可能需要一些调整。

RewriteEngine on 
RewriteBase/

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^.]+?)/?$ $1.html [R=301,L,NE] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^.]+)\.html$ index.php?_route_=$1 [L,NC] 
+0

它的工作,但这种方法将把每个链接.html。我只需要在产品页面。原因是我会重拍一个网站,SEO人员希望所有链接都与旧网站相同,只有在产品页面最后是'.html'。 –

+0

,如果你用'index.php?route = product/$ 1'替换'index.php?_route _ = $ 1' –