Opencart 1.5x - add '.html' at the end of product url

336
March 01, 2017, at 06:43 AM

How can I add at the end of product url the extension '.html'.
-My current product link:
www.mysite.com/productlink
-I want to be:
www.mysite.com/productlink.html

I edited catalog/controller/common/seo_url.php, the product url now has .html but when I click a link it says 404 not found. What do I need to do ?

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]);
}       
Answer 1

You can do this by using .htaccess try this: I haven't tested this so it may need some tweaking.

 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]
Rent Charter Buses Company
READ ALSO
How to upload videos to Google Drive?

How to upload videos to Google Drive?

I have created Google Service account and successfully connected my app with google drive

372
translate bibTex file into an XML file using PHP

translate bibTex file into an XML file using PHP

I need to import bibTex bibliography to a website that is using SWORD web service

329