The way that Oscommerce SEO Friendly URLs work, is that they are generated from a product or category title followed by a p for product and c for category, then the product or category ID. For categories, each parent directory ID is also used. for example:
https://example.com/jeep-pinion-gears-c-284_845.html
over the course of many years, products and categories get edited and moved therefore changing the URL. However, all the old URL's still resolved because pages are served strictly based off of the last part of the URL. It looks for the c or p and the ID's. SEO is still able to be maintained. For Example:
https://example.com/jeep-pinion-gears-c-284_845.html
https://example.com/jeep-pinion-gears-and-accessories-c-284_845.html
https://example.com/jeep-pinion-gears-c-284_1234_845.html
https://example.com/ring-pinion-gears-c-845.html
Would all load the same content.
I've recently changed over to OpenCart where I used the latest URL for each product and category from the OsCommerce store. However, all the of Old Oscommerce URL's don't work.
I was originally writing some regex redirects to match the ID's but I'm running into redirect loop issues.
Does anyone any any ideas on a different approach?
If there is a way to derive the new OpenCart URL from your OsCommerce SEO URLs
RewriteCond %{REQUEST_URI} !^/.*?-[cp]-\d+\.html$
RewriteCond %{REQUEST_URI} ^/(.*?)-([cp])-[\d_]*?(\d+)\.html$ [NC]
RewriteRule (.*) https://new.example.com/%2-%3.php [R=301,L]
The important part here is the stop not rule to prevent looping redirects.
put it below others rewrites, removing a trailing slash or the www-subdomain, or http
to https
rewriting.
If three is no "simple relationship" between the two URLs you are out of luck and have to write a redirect for each of them. You should be able to generate the rules using the SEO URLs stored in the DB.
Redirect 301 /old-page.html http://www.example.com/new-page.html
Maybe a PHP redirect could be helpful too?
header("Location: http://www.example.com/new-page.html", true, 301);
exit();