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.
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_aliastable for any keyword matching$this->request->get['_route_'].The second extends the
rewrite()function to look in theurl_aliastable 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/cart