0

I imported all content from an old site to a new one.

The old site was basically a catalog of products and blog posts. However, it was all built as standard WP posts - not custom post types.

The new site has a blog and WooCommerce implemented, so I managed to divide all of the old posts into Post/Products, and old categories into Cats/Product cats.

However... The old permalinks were set to %category%/%post%, so you can't tell by the URL, whether it is a link for post, or for a product.

I need to set the redirects globally so the old links get redirected like this:

For products:

  • FROM /some-category/some-product-name/
  • TO /product/some-category/some-product-name/

For product categories:

  • FROM /some-category/
  • TO /product-category/some-category/

For blog posts:

  • FROM /some-category/some-article/
  • TO /blog/some-category/some-article/

For blog categories:

  • FROM /some-category/
  • TO /blog/some-category/

Or something similar, that would work in the same manner. I already tried some plugins like Redirection, but it's settings don't seem to match my needs. Is this even remotely possible?

  • 1
    The Redirection plugin could actually help you, but you could also try with add_rewrite_rule(). But you'd need to know/find the exact post/product/category slugs. – Sally CJ Oct 5 '18 at 9:14
0

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.

  • 1
    Thank you. I actually tried Redirection, but it turned out I just had to learn more about regular expressions to achieve what I want. – Kristián Filo Oct 5 '18 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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