Enable SEO friendly URLs in Opencart

We can easly create the SEO friendly URL in Opencart. Just followed the some steps in opencart admin and add the some code on .htaccess file.

Kindly follow the steps:

Login to your OpenCart admin panel.
Navigate to System > Settings and click the “Edit” link.
On the “Server” tab, set “Use SEO URL’s” to “Yes” and save the changes.
Now go to the category/product and click on edit link, then go to the Data Tab and write your desire url in SEO Keyword field.

And add this code on .htaccess file

 

RewriteBase /

RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^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]

If your project are located in folder then add the folder name

For example :

RewriteBase / (If project located on root)
RewriteBase /add folder name here/ (If project located in any folder)

 

How to add cononical tag in opencart

We have found the way to add the canonical tag on OpenCart website in a easy way…

First we find the catetory.php file from the category folder

catalog/controller/product/category.php file

Find this line:

if ($category_info) {

and add the following lines after that

$can_url=$this->url->link("product/category","path=".$this->request->get[‘path’]); $this->document->addLink($can_url,”canonical”);

Second we find the catalog controllers file

catalog/controllers/common/home.php

Find this line:

$this->document->setDescription($this->config->get(‘config_meta_description’));

and add the above code after that

$can_url=$this->url->link(‘common/home’);
$can_url=str_replace(‘index.php?route=common/home’, ”, $can_url);
$this->document->addLink($can_url,’canonical’);