Support » Fixing WordPress » Redirect my 2020 and 2019 posts

  • Hello,
    I will delete every posts of 2020 and 2019. I would like their links to be redirected to https://website.com/blog/ to avoid 404 pages. Do you know a method to redirect all links in one go from my 2020 and 2019 posts? I would like to keep my actual permalink: https://website.com/%postname%/

    I have a quite a lot of posts and I don’t feel like doing them one by one. So, I was wondering if you knew of a plugin or a solution that could do the job? Or is it impossible to do with my type of permalink?

    Thank you

    • This topic was modified 3 months, 3 weeks ago by Jan Dembowski.
    • This topic was modified 3 months, 3 weeks ago by mbourgeault.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Redirect them to where? And are you changing or have you changed your permalink structure? Can you please give more details?

    For any automation to work, a common trend or pattern has to exist.

    Eg, if you changed your permalinks from /year/month/day/postname/ and want to redirect all old posts to the new /postname/, here there’s a common pattern for all the posts: the /year/month/day/ that has to be removed for all posts.

    Thread Starter mbourgeault

    (@mbourgeault)

    Thank you for your interest.
    I will delete every post of 2020 and 2019. I would like their links to be redirected to https://website.com/blog to avoid 404 pages. I would like to keep my actual permalink (https://website.com/%postname%/)

    Redirects can either be done from the webserver (eg using htaccess rules), or by WordPress (using a plugin or custom code).

    To be able to redirect a group of URLs directly from the webserver, we need a common pattern for all the URLs that make up that group. With your permalink structure, there cannot be any common pattern between the different URLs that you want forwarding, making this not a viable option.

    We could use WordPress to identify this group of posts by their publication date and forward the URLs, but only while the posts exist. Once the posts are deleted, all information about the posts is purged, and WordPress cannot have any knowledge of the publication date of a post that doesn’t exist anymore. So here too we cannot automatically identify just these URLs and forward them.

    So I see to possible routes to take:

    1) You can make a list of ALL the URLs (your 2020 & 2019 posts) that you want to forward to the blog index page. Then you can pass this list to a WordPress plugin like Redirection (easier), or write custom htaccess rules (faster) to forward these URLs.

    2) Another option, if you don’t want to make and maintain such a list, is to simply delete the posts and redirect ALL requests resulting in 404-page-not-found to the blog posts page, or a specially-crafted page with useful and relevant information (not the usual “Page Not Found”). It’s important to note this will be for ALL non-existing URL requests to your site, and not just these deleted posts.

    Good luck!

    Thread Starter mbourgeault

    (@mbourgeault)

    Thank you very much for your answer.
    These were also the solutions I had come up with.
    The 404 one is really what I was searching for.
    I was hoping to find another alternative.

    On another site someone told an idea that won’t take long to do.
    I share it here, if it can help anyone other than me:
    I exported the dates and permalinks of my posts with WP All Export. I modified the .csv to keep what I wanted and add a redirect column I wanted.And I imported the file with a redirection plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.