How can you customize system URLs in OpenCart? For example, I would like http://example.com/index.php?route=checkout/cart to be displayed as http://example.com/cart
I know OpenCart provides SEO URLs for products, categories, manufacturers and information pages, but it doesn't look like there is anything built-in (at least prior to version 1.5.0) for anything else.
I'm using Opencart version 1.5.5.1 and this is the exact code that worked for me:
Depending on the level of customization you need, there are a few extensions available, including free ones.
This one works both on OpenCart 1.5 and OpenCart 2 and seems quite customizable. However it does not support customization of hardcoded URL parts like "checkout/cart" or "account/wishlist".
Here is a vQmod for OpenCart 2.0 (might work with 1.5, not tested) which applies to the forementioned extension and allows to change these hardcoded strings into whatever you want, and support multilanguage websites.
E.g. "checkout/cart" will become "cart" for English, "panier" for French, etc.
It turns out this can be done with a relatively simple change to a single file. No .htaccess rewrite rules, simply patch the catalog/controller/common/seo_url.php file and add your pretty URLs to an existing database table.
The patch to seo_url.php:
There are two edits required. The first extends the
index()
function to look in theurl_alias
table for any keyword matching$this->request->get['_route_']
.The second extends the
rewrite()
function to look in theurl_alias
table for all routes, not just those for products, manufacturers, and information pages.Adding entries to the database:
That's it. http://example.com/cart should return the same thing that http://example.com/index.php?route=checkout/cart does, and OpenCart should recognize
$this->url->link('checkout/cart');
and return a link to the pretty URL http://example.com/cartPut this near the top of your index.php file. It was the only solution that worked for me.
OpenCart SEO for OpenCart 1.5.X free :)
You can use as you wish. Category Name / ID / ID for quicker SEO resolving
A simple "no code" method is to install vQmod. Instructions here: vQmod install wiki
And then upload the xml file available in this Opencart forum thread to the vqmod/xml/ folder.
The xml contains a relatively easy to read script that maps the urls similar to the two answers above, but without modifying core files. So site updates will not kill it.