0

We recently moved from Magento 1 to 2, during the move we cleaned up our category urls to be more consistent. For instance we changed:

/mens/mens-accessories/mens-wallets

to :

/mens/accessories/wallets.

SEO wise this is really destroying us and was wondering what the NGINX rewrite would be to

a) redirect the old category url to the new one and

b) make old product links work as before so that:

/mens/mens-accessories/mens-wallets/product-from-the-category 

will redirect to:

/mens/accessories/wallets/product-from-the-category
1

By using the rewrite rule below

rewrite ^/mens/mens-(.*)/mens-(.*)$ /mens/$1/$2 permanent;

The nginx server should redirect (301) both of your category page and product page

Please note that this is only redirecting one category (mens) and products.

If you need redirection on other categories and products, then you would have to write additional rules to accommodate them.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.