Last Updated: January 4, 2021 | 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
And paste the regular expression (Regex) syntax below. Here are some commons regex use interm of default WordPress permalink.
Redirect from Date (Year/Month/Date) Format to Archive 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/
Redirect all URL Except wp-admin
SOURCE REGEX: ^\/((?!wp-admin).)*$
TARGET REGEX: https://newsite.com/$1/