Opencart version 2.3, the task was to make all URLs like /category/subcategory/product and remove links to http://domain-name/product (from the root). Duplicates for SEO are not cool, the task is simple.
To combine URLs and bring them to the standard, it is enough to select Seo Pro in the System – Settings – Edit – URL Type section (if it is not in the list, you must first install this modifier), and then select the URL of products with categories.
At this stage, we get normal URLs with full path indication, automatic redirect from old URLs (for example, if products were placed in the root of the site), but for categories we automatically add /. If the ending is relevant on your entire site with a slash at the end, it’s ok. But if the task is to remove slashes and redirect from slash to without slash, you need to edit the file/catalog/controller/startup/seo_pro.php, find lines 240-244:
if (isset($postfix)) { $seo_url .= trim($this->config->get('config_seo_url_postfix')); } else { $seo_url .= '/'; }
and remove the slash here:
$seo_url .= '/';
You can replace these lines with:
if (isset($postfix)) { $seo_url .= trim($this->config->get('config_seo_url_postfix')); } else { $seo_url .= ''; }
Redirect will appear automatically, there are no more duplicates on the site.