I have an old site with thousands of products and some SEO ranking and I wanted to redirect URLs using .htaccess
, hopefully without manually writing thousands of 301 redirect entries.
The domain stays the same but url structure is different
Old website
example.com/category/sub-category/2350-Product-Name
(URL has an id and Capitalized letters)
New website
example.com/different-category/different-subcategory/product-name
(URL has no id and no lowercase letters)
if I used the code below, would it be enough for a successful redirect?
# 301 Redirect URLs.
Redirect 301 /example.com/category/subcategory /example.com/different-category/different-subcategory
I found this code in another thread, which, if I understand correctly, redirects to category/subcategory that can consist of the characters a-z, A-Z, 0-9, _ (underscore) or - (hyphen), but I'm not sure how to piece this all together
RewriteRule ^([\w-]+/[\w-]+/)$
.htaccess
.