Relative redirects for posts, categories, products and product categories

OK, so here’s the first time I’m going to recommend a plugin as a solution… But it’s really the easiest solution in this case, I guess…

There’s a great plugin called Redirection in plugin repository (https://pl.wordpress.org/plugins/redirection/).

It allows you to define all kind of redirections. You can decide if it should be 301 or 302 redirection, you can use regex, and it even counts redirected requests, so you know when a rule is not needed anymore…

PS. Of course you can do this without any plugin at all. Just add these rules to your .htaccess file.