OpenCart 3.x comes with an easy to enable SEO URLs, from the OpenCart admin. I had a couple of issues getting this working properly, here’s what I did;
- Login to your OpenCart admin panel.
- Navigate to System > Settings and click the Action “Edit” link.
- On the “Server” tab, set “Use SEO URL’s” to “Yes” and save the changes.
We need to now tell the web server what to do with our SEO options;
- OpenCart provides a file called .htaccess.txt in the install directory. Rename it to .htaccess. If you have already created a .htaccess file, add this code at the end of the file:
Note: if you have installed your OpenCart in a sub directory then you will need to change the RewriteBase directory to reflect this;
So, you’re good to go. You can now add SEO keywords to your Category and Product definitions, remember they need to be unique and must not contain spaces, use a ‘-‘ to separate multiple words.
- Navigate to Categories or Products and click the Action “Edit” link next to the Category or Product you want to update.
- On the “SEO” tab, add a unique keyword and save the changes.
At this point your SEO should be working but you may notice that many of the links in the footer have original style links and are not SEO links.
You could find a plugin to do the remainder but I didn’t;
As an example here is how to change the Contact Us and Return URLs
- Edit the following file;
- Locate the following lines
- Replace the RED bracketed code between the ” ” with the SEO keyword you want.
- Now we need to tell the web server to reWrite the new SEO rules specifically. Edit you .htaccess file and add the following lines after your ReWriteBase line.
- The BLUE URL is what you will see if you hover over a footer link or in the browser address bar if you click a link. Take everything after you website name i.e. http://<websiteName>/index.php?route=account/return/add
One last thing would be to refresh the OpenCart cache. You do this from your admin dashboard by clicking the top right settings icon then click the theme refresh icon