OpenCart: Clean SEO URL’s for Contact Us, Site Map and other custom pages

There is a Mobile Optimized version of this page (AMP). Open Mobile Version.

Over the last few weeks I have been working with OpenCart, a free Open-Source Shopping Cart. And so far I have been loving it!

However it was not long until I hit a road block with the software, after enabling the clean SEO URL’s feature and setting up my “SEO Keywords” for all my products, categories and information pages. I soon realised there was no options to set this up for the Contact Us, Sitemap and various other pages!!

I soon figured it out though, and I will explain how to do this for the contact us and site map pages below:

First modify /catalog/controller/common/seo_url.php

add:

//custom SEO url's
if ($url[0] == 'contact') {
    $this->request->get['route'] = 'information/contact';
}   
if ($url[0] == 'sitemap') {
    $this->request->get['route'] = 'information/sitemap';
}

 

after:

if ($url[0] == 'information_id') {
    $this->request->get['information_id'] = $url[1];
}

 

Now you need to insert two URL aliases into your url_alias table with the following values:

 

Column: Value: 
 query contact=contact
 keyword contact
 query sitemap=sitemap
 keyword sitemap

 

Congratulations! It is that simple! You can now link to http://yoursite.com/contact or http://yoursite.com/sitemap.

All you need todo now is repeat the steps above to create URL aliases for any page in open cart.

Author: Dean Williams

I'm a Web Developer, Graphics Designer and Gamer, this is my personal site which provides PHP programming advice, hints and tips

Post Tags:
, , , , , ,