Bulk Redirecting categories to tags

I have a site which has tons of categories which I converted to tags. I am trying to figure out a way of auto redirecting any categories which have a 404 error to the corresponding /tag/ url instead of /category/

Any advice? Maybe a .htaccess script?

  • jeff arnold
    • The Incredible Code Injector

    I don't know how many a 'ton' of categories are, but I've done this using a URL scraper and setting up the redirects with the 'redirection' plugin.

    If you have the list of categories, you can put them into a CSV file (Column A), then match them with the tags (Column B). I use the concatenate function to do this fairly often.

    So you could have:
    Column A Column B
    /category/1 /tag/1
    /category/2 /tag/2

    You can bulk upload the redirects using that plugin and it will redirect everything.

    Jeff

  • Vinod Dalvi
    • WP Unicorn

    Hi @nomadone,

    I hope you are well today and thank you for your question.

    @jeff arnold has provided good answer in his last reply.

    Alternatively if you don't want to use any plugin and redirect all categories to tags then you can directly add following code in your .htaccess file.

    RewriteEngine On
    RewriteBase /
    RewriteRule ^category(?:/[^/]+)*(/[^/]+) tag$1 [L,R=301]

    Please check it and let me know if you face any issue implementing it.

    Best Regards,
    Vinod Dalvi

  • nomadone
    • The Incredible Code Injector

    Hi Thanks for this information.

    I am however aware of general regex for redirecting ALL cats but only want to redirect category links which no longer exist, meaning they were converted to tags. I can't redirect ALL categories.

    thanks

  • Vinod Dalvi
    • WP Unicorn

    Hi @nomadone,

    only want to redirect category links which no longer exist, meaning they were converted to tags. I can't redirect ALL categories.

    You can achieve this by developing custom code to check whether category exists or not as displayed on the following reply.

    http://wordpress.stackexchange.com/a/121312/14347

    If you are not a programmer then you can consider hiring a developer from https://premium.wpmudev.org/wpmu-custom-development/ to develop it for you.

    Cheers,
    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.