What is a 301 redirect?

301 redirect tells the search engine that the Web page has been permanently moved to a new location.

What is htaccess?

This is an additional Apache web server configuration file. It is located in the root folder of the site.

How to make a 301 redirect for Opencart?

To do this, you must write a special rule in the .htaccess. The following design is used for the Apache web server:

RewriteCond %{QUERY_STRING} ^_route_=(Old url without a domain)$
RewriteRule ^(.*)$ (New url with domain and https)? [R=301,L]

Brackets are used only for highlighting text. Do not use it in the real case.

For example, the old page has address: https://old.site.ua/old-category/old-product

You need to set up a redirect to a new address: https://new.site.ua/new-category/new-product

So, we write the following:

RewriteCond %{QUERY_STRING} ^_route_=old-category/old-product$
RewriteRule ^(.*)$ https://site.ua/new-category/new-product? [R=301,L]

Redirect for multilingual sites.

Let's imagine that site content is also available in Ukrainian. And url has a prefix /uk: https://old.site.ua/uk/old-category/old-product

and we redirect it to a new address: https://new.site.ua/uk/new-category/new-product

then the htaccess line will look like this:

RewriteCond %{QUERY_STRING} ^_route_=uk/old-category/old-product$
RewriteRule ^(.*)$ https://site.ua/uk/new-category/new-product? [R=301,L]