1. Home
  2. Knowledge Base
  3. How to Redirect Posts After Changing URLs

How to Redirect Posts After Changing URLs

If you’ve ever come across a poorly optimized URL on your website and decided to change it to a more user-friendly URL — it’s great! But what if your visitor lands at your old URL and sees a 404 error instead of your well-written piece of content.

So it is important to ensure that your old URL gets redirected to the modified one whenever you change your URLs. And guess what — when you’re redirecting your URL, you’re also passing the link juice to the new one. Although you’ll be losing some link juice in this process of redirection, it is relatively better than a new URL with no backlinks.

Redirecting Posts After Changing URLs

In this tutorial, we’ll show you how to redirect the URL of your post so that you can help your visitors and search engines reach the right page with your content.

1 Automatic Redirection by WordPress

If you’re changing your blog post’s slug, then WordPress will automatically redirect the URL of your old post to the new one without any extra effort from your side.

However, the WordPress automatic redirection feature is limited only to posts and cannot be used for redirecting pages, taxonomies, and CPTs.

2 Rank Math Auto Post Redirect

If for some reason, WordPress doesn’t automatically redirect your old URLs to the new ones, thankfully Rank Math can help you redirect your posts automatically.

To enable this automatic post redirection feature of Rank Math, you need to ensure that you’ve activated the Redirections module by navigating to WordPress Dashboard > Rank Math > Dashboard > Modules.

Activate Redirections module

Once you’ve activated the Redirections module, head over to the WordPress Dashboard > Rank Math > General Settings > Redirections > Auto Post Redirect and enable the option.

Enable Auto Post Redirect

Once you’ve enabled this option, click the Save Changes button for the configurations to take effect.

Rank Math’s Auto Post Redirect is not limited to Posts and helps in creating automatic redirections for posts, pages, taxonomies, and CPTs. But, please note, these redirects are always of type 301 Permanent Redirection.

3 Set up Manual Redirection with Rank Math

Alternatively, you can also set up a manual redirection with Rank Math. To create a manual redirection with Rank Math, navigate to WordPress Dashboard > Rank Math > Redirections.

Rank Math redirections

You will reach the Redirections page, which would look like this.

Redirections page - Rank Math

Now, click on the Add New button so that you can create a redirection. When you click the button, you’ll be prompted with a form like this at the top of your list.

There are plenty of options available here and we’ll go through the importance of each option:

Source URLs

Enter the URL or URLs (in case, if you’ve more than one URL) from where you want your visitors to redirect from.

You can either add your Source URLs with their full URL(with the https protocol and the domain name) or just add the address from the document root (the first “/” after your domain name) — and let Rank Math automatically add the domain name and slashes in the source URL.

Rank Math source URLs for redirection

Match Type

By selecting the Match Type, you can let Rank Math know how you wanted the Source URLs to be matched with the URL a visitor would use to land on your website.

You can use any one of the following:

  • Exact Match — To match the URL exactly with the one your visitor would be using to land on your website.
  • Contains — The URL will be matched and redirected when it contains a particular term you’ve added to the Source URLs field.
  • Start With — To match all those URLs that start with the keyword you’ve entered in the Source URLs field.
  • End With — To match all those URLs that end with the keyword you’ve entered in the Source URLs field.
  • Regex — To match all those URLs with the regular expression pattern you’ve used in the Source URLs field.

Destination URL

The Destination URL is where you want to redirect your visitors. You can either enter the full URL or only the address after the document root to this Destination URL field.

Enter the destination URL

Redirection Type

The Redirection Type you’re setting here would help communicate the type of redirection to the search engines.

Although there are various types of redirection, you’ll find only the commonly used redirection codes being listed here:

  • 301 Permanent Move — A 301 code represents that the old URL has been permanently moved to the new URL and would not be coming back again
  • 302 Temporary Move — A 302 code represents that the redirection is only temporary and hinting the search engines that you will use the original URL once again
  • 307 Temporary Redirect — A 307 code indicates another temporary redirect, but technically a bit different from 302, as it communicates search engines to use the same HTTP method as earlier.

Select the redirect type from these options or from the maintenance code (which we’ll cover next). By default, 301 Permanent Move is chosen as the Redirection type.

If you want to change the default redirect for the manual redirection, from 301 Redirection to other types of redirection like (302, 307, 410, 451), then you can change it under Rank Math > General Settings > Redirections > Redirection type.

Maintenance Code

A maintenance code is technically not a redirection code, but it would be more relevant to set one in cases where you need to inform search engines that the old content is no longer available.

Currently, you can find these two maintenance codes available:

  • 410 Content Deleted — If your content is deleted, you can set the maintenance code to be 410
  • 451 Content Unavailable for Legal Reason — If the content on your website has to be restricted to a demographic or age group or any other legal reason, you can set the maintenance code 451.

Redirection Category PRO

Rank Math understands the difficulties of managing a large number of redirections, so it has a feature that allows you to categorize your redirections. Although it is optional to add a redirection category, it would be useful to classify them, if you’re planning to create a number of redirections.

You can either choose an existing redirection category (if you’ve already created one) or click Add New button to create a new redirection category.


Managing redirections with Rank Math is a lot easier. You can easily activate and deactivate redirections by toggling on/off the Status option.

Activate and deactivate redirection

Once you’ve configured the redirection settings, click the Add Redirection option to create your redirection.

Add Redirection

If you’re changing the permalink structure to a more clear and user-friendly one, then you may have to create as many URLs on your website, depending upon your website’s size. But creating all those redirections manually would be a tedious task and unnecessary.

However, creating redirections in the case of a change in permalink structure couldn’t be easier than using Regex (Regular expression) with Rank Math.

For instance, if you’ve removed a specific term from the permalink structure (say wordpress-tutorials) and you want to redirect your website visitors to the modified URLs, then you should add the following regex in the Source URLs field.


And the following regex should be added in the Destination URL field — don’t forget to replace your domain name.


This would look something like this.

Creating regex redirect for change in permalink structure

Once you’ve added the settings, click Add Redirection button for the changes to take effect.

Now, when a visitor lands on a page with a URL https://example.com/wordpress-tutorials/install-plugin/, it would be redirected automatically to https://example.com/install-plugin/ and the same happens for all URLs with this permalink structure.

This is a simple use case for regex — however, you can use regex for even more complicated patterns. For a deeper understanding of using these regular expressions, you can refer to this documentation.

And, that’s it! If you have any questions about redirections, we recommend reading through our detailed knowledgebase articles on redirection settings and solving redirection issues. If you’re still facing any redirection issues, feel free to reach our support team – we’re always more than happy to help.

Was this article helpful?

Still need help?


Submit Your Question

Please give us the details, our support team will get back to you.

Open Ticket