How to Enable SEO URLs in OpenCart 2.x (Apache and NGINX Servers)
SEO in OpenCart is one of the starting points when you are building your store. If you know a little about search engine optimization, you will probably know that links are one of the most powerful factors for the ranking of any website.
OpenCart supports SEO-friendly URLs, however they are not enabled by default.
This tutorial will show you how to do that and what needs to be done outside of the admin panel for the SEO URLs to work.
Enable SEO URLs
To enable this setting, you need to log into your admin panel and go to System > Settings > Server. Then you need to select Yes on the Use SEO URLs field.
Rename .htaccess File
However, you might notice that this field has a little info box. Hover over the small blue question mark to see it.
It states:
To use SEO URLs, apache module mod-rewrite must be installed and you need to rename the htaccess.txt to .htaccess.
Important:
These instructions are only valid for OpenCart stores running on Apache-based servers.
To modify your .htaccess.txt file, you need to access your source files (in FileZilla for example). The screenshot below shows you where the .htaccess file is located.
It has already been renamed from .htaccess.txt to just .htaccess.
This is pretty much it. If you are running on an Apache server, you are all set now and you can skip the NGINX instructions to see how the SEO URLs are configured in your OpenCart categories and products.
NGINX Server Instructions
With NGINX servers, it’s a bit more tricky and there are some server configurations that need to be done. Contact your server administrator for access to your configuration settings. When you access them paste the code sample from line 5 to line 15.
server { ... ... location / { try_files $uri @opencart; } location @opencart { rewrite ^/(.+)$ /index.php?_route_=$1 last; } location ~* (\.(tpl|ini))$ { deny all; } }
Configuring SEO URLs
To customize your SEO URLs for your products, go to your admin panel, select Catalog > Products, edit a product, go to the Data tab and scroll down until you see the SEO URL field.
You can configure the URL in any way you like.
Important Note:
The SEO URL field should contain unique phrases so you don’t risk ending up with duplicate URLs. OpenCart does not have a duplication checker, which might lead to inaccessible products if you enter the same URL twice.
Your OpenCart categories can also have custom SEO URLs. It’s the same as the products, go to Catalog > Categories, select a category and go to the Data tab to find the same SEO URL field to customize.
You can do the same for all the Information pages in your OpenCart store as well, for an extra SEO boost. Go to Catalog > Information, choose the information page you want to edit and go to the Data tab to find the SEO URL field.
Summary
That is all. Your SEO URLs will now be enabled and working. If you want to be sure that you are configuring your URLs for maximum impact, check out this article from Moz. It explains the best practices for setting up your URLs, their optimal format keyword relevancy, etc. Let us know if you need any help in the comments below!