Redirect From Old URL to New URL Format in WordPress

Last Updated: September 20, 2020 | Reading Time: 2 minutes

Working on redirect from old URLs to the new one in WordPress is quite simple, this technique is useful to keep the traffic going to the correct post if you have changed your URL. Here are steps on how to set up a redirect with simple REGEX command to bulk redirect posts to new URLs.

Setup the Plugin

First step is to install the Redirection plugin. This is my most favorite plugin for logging 404 and redirect them into the correct urls.

Once it set up, go to the plugin settings, tools > redirection, and add new redirect, and activate the regex option

Setting up Regex using plugin
Adding Regex for Redirection
Adding regex redirection example
Example how to add regex redirect

And paste the regular expression (Regex) syntax below. Here are some commons regex use interm of default WordPress permalink.

Redirect from Date Format to Category Format

Old date based-format like this:

SOURCE URL: /2019/02/28/mammoth-hello-camp-2019/
REGEX: ^/\d{4}/\d{2}/\d{2}/(.*)

Redirect to:

TARGET URL: /archive/mammoth-hello-camp-2019/
REGEX: /archive/$1/

Redirect all url on this site to new site address.

OLD URL: /mammoth-hello-camp-2019/
REGEX: /(.*)

Redirect to new site address:

TARGET URL: https://newsite.com/mammoth-hello-camp-2019/
REGEX: https://newsite.com/$1/

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

    Any idea? Fill the comment below

    This site uses Akismet to reduce spam. Learn how your comment data is processed.