I’m using Opencart 2.x version and shop installed in /shop subdirectory.
I know how to enable seo_url (.htaccess.txt -> .htaccess, set RewriteBase to /shop/ and enable SEO urls in admin panel).
Seo urls works and my links like information/information_id=1
changed to /faq
etc.
Problem is that if I add in url_alias table records: inforamtion/contact = contact
– this url works, but on the site it still looks like /shop/index.php?route=information/contact
not as /shop/contact
I supposed that it should be changed automatically, but not. All site’s links for product, categories and information pages had been changed, but that added by me manually – NOT. Why?
PS: I can change it in code, but think it is not good solution cos suppose exists correct way to do what I need.
2
Answers
Where abouts on the front-end are the non-SEO friendly URL’s (the ones with index.php?route= in them) appearing? If you’ve copied/pasted any into markup in your templates they will remain as they are. Opencart also has various redirects and things hard-coded into it’s controller files which might redirect to such a URL. So it depends where these links are on your site.
I’m not really sure if you have already got an answer to your question, but I’ll leave it here anyway, since it took me a couple days to figure this one out.
In order to change from
/index.php?route=information/contact
to just/contact
, you require two steps(You probably got step 1 ready already)
catalog/common/seo_url.php
file to look like the following:This will rewrite all the links to whatever SEO keyword you assigned to that route on your url_alias table.
And that’s it! Hopefully this helps more people, because it’s a pain to dive in all that code.