Advanced Redirection User guide, the best WordPress plugin for making redirects

If you follow the blog for a long time you’ll know that Redirection is always among my favorite plugins of all time. It’s not that it’s complete, it’s just that it works better than any other paid premium plugin when it comes to creating and managing redirects in WordPress.

But there is one problem, and that is that most people don’t know how to use it or use it badly. So my goal with this guide is to teach you how to correctly use and take advantage of this jewel of WordPress programming: Redirection.

Do I need to make redirects?

Don’t doubt it, it should be one of the first plugins you install in any WordPress website, because its main function, creating redirects, is a basic SEO tool.

Even if you don’t know it, or haven’t realized it yet, you will need to do redirects with total security, and more times than you imagine, throughout the life of your website.

You will need to do redirects to…

  • Avoid penalties for “404 not found errors” when deleting an entry or page
  • Avoid penalties for “404 not-found errors” if you change the URL of an entry or page.
  • Avoid penalties for multiple 404 errors if you change your site’s permanent links.
  • Redirect old URLs to new URLs in case of major content changes or posting dynamics.
  • Unify old content in a new URL to avoid penalties for the cannibalization of content.
  • Etc…

Are redirects good?

It’s not really an ideal situation. In a perfect world you should not do redirects if you can avoid it, because it always means a delay in delivering the content, as the browser/user is taken to the original URL, and from there – by redirecting – to the destination URL, and this always means longer waiting times than going directly to the original URL.

However, even if they are not ideal, a redirect is always better than a content not found error.

This is why you should avoid having to make redirects, or at least make as few as possible.

Some tips to avoid having to do too many redirects are

  • Set up your website’s permanent links correctly as soon as you install WordPress. Think about it, so you don’t have to make changes later, and have to create redirects.
  • Customize the slug of each entry or page before publishing it, to avoid the temptation to change it later.
  • Avoid publishing too much similar content, to avoid cannibalizing content and having to generate new URL structures to avoid them.

Do I need a plugin to make redirects?

Not really, there are several ways to do redirects, and although in this guide we will learn how to do them with the Redirection plugin, you could also do them manually.

Redirects in .htaccess

A common way to create redirects is to do them directly in your server’s .htaccess file, like this

RewriteEngine On
Redirect 301 /old-entry-slug/ language: JavaScript (javascript)

But this manual method has a couple of problems:

  1. It is very easy to break something by “touching” important configuration files such as .htaccess
  2. You have to do them all manually.

Redirects with a function

You can also do it using a WordPress function, as in this example:

function wphelp_redirects() {
     if (isset($_SERVER['HTTPS']) &&
        ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
        isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
        $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
        $protocol = 'https://';
        else {
        $protocol = 'http://';
    $currenturl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    $currenturl_relative = wp_make_link_relative($currenturl);
    switch ($currenturl_relative) {
        case '[original slug]':
            $urlto = home_url('[destination slug]');
       case '[original slug2]':
            $urlto = home_url('[destination slug2]' );
    if ($currenturl != $urlto)
        exit( wp_redirect( $urlto ) );
add_action( 'template_redirect', 'wphelp_redirects' );Code language: PHP (php)

Just change the source and target slugs for real ones, or add more. You can put the above code at the end of the functions.php file of the active child theme or in your customization plugin.

That said, the ideal is to do it with a plugin that allows you to …

  • Make manual redirects.
  • Detect URL modifications and deletions to automatically generate redirects.

And among all of them, the best one is undoubtedly Redirection.

Redirection Installation

Having said all this, we are going to go to the limit with Redirection, reviewing its possibilities from the very installation, to avoid the mistakes that I usually find in client installations.

The first thing is to install the plugin like any other.

Once installed and active you will see a message that encourages you to configure it, which is just what you need to do at this time. Let’s see how to do it correctly.

The Redirection setup wizard

The link we saw just after activating the plugin leads us to a setup wizard, very important for the proper setup of the plugin.

So after clicking on the button to start the setup welcome screen, we will find the first decisions in the basic configuration settings.

As you see in the screenshot, there are 3 possible options to activate, and these are my recommendations:

  • Monitor permalink changes in WordPress: Enabled for Redirection to create automatic redirects and not lose traffic or show 404 errors.
  • Keep a log of all redirects and 404 errors: Enabled, especially for monitoring 404 errors, which you can later review in the plugin settings and easily create redirects.
  • Store IP information for redirects and 404 errors: Disabled, because it is unnecessary for the operation of the plugin and activating it would entail more responsibility regarding the privacy of your users and possible breaches of privacy laws such as RGPD.

And we continue with the configuration so that in the next step, Redirection checks if it can connect correctly with the WordPress REST API.

Normally you will be able to perform the test without problems, but even when some security plugin or code is blocking the WordPress REST API, the Redirection Plugin will almost always be able to continue working.

We can now finish and Redirection will create the needed database tables.

Is it that easy? Does it all work?

Well, no, and this is usually the main mistake of most people when installing Redirection: thinking that by doing the initial configuration everything is already well configured and you have nothing else to do.

Nothing could be further from the truth…

How to configure Redirection correctly

When you finish the assistant you must go to the plugin options, to correctly configure Redirection. To do this, the first thing to do is to go to its settings pages, in Tools -> Redirection -> Options.

Apart from making a donation to the author of the plugin, don’t forget, the most important settings are the ones I marked in red in the previous screenshot.

In the first two we will decide how long the plugin will save the redirect and 404 error logs that we indicated to be made in the assistant.

My advice is to leave it in a week, but to check at least once a week the plugin’s 404 error page, to generate the redirects that were necessary, if applicable.

If not, then adjust it to your own schedule, but be consistent with your responsibility when reviewing errors, and trying not to be too long, so as not to occupy unnecessary space in the database.

In the following boxes, called “URL Monitor:” is where we will tell you what changes in URLs and where you should monitor the plugin, so that it generates the necessary automatic redirects in case of changes.

And then, indicate in which group of redirects to save the previous ones, being able to choose between the existing ones (which the plugin automatically creates) or the ones you create.

But it is the following settings that are perhaps the most important, and those that most users ignore or do not know how to use.

  • Default Query Match: I recommend using the exact match, so as not to lose any parameters of the original URL.
  • AutoGenerate URL: This is used for tracking when you do redirects. The most recommendable and usual is to leave it blank, but you can add in the field something like /follow/$hex$ or /follow/$dec$ so that the URLs of the type /follow/12a34b56c are created. But I tell you that the normal thing, and that I recommend you, is to leave it blank.
  • .htaccess of Apache: This is the mother of redirects, but later I explain to you how to configure this and why.
  • Redirect cache: This is used to control the cache of the users’ browser. The rule is: if you do a lot of redirects every day put it on “Never cache” or “One hour” to make sure visitors always see the correct destination URL of the redirects and avoid errors, but if you almost never do redirects better put it on “A day” or “A week” to generate fewer queries to your server.
  • API REST: If everything works, if the redirects are done correctly and they work, leave it at “Default REST API”, only in case of errors connecting the plugin to WordPress change it to “API REST raw/relative”. It usually works fine by default.
  • Delete Redirection: Pressing the “Delete” button will disable the Redirection Plugin and all its redirect, error, and setting records, so don’t even think about pressing it unless you have decided to stop using the Plugin permanently.

And that’s it for the most important options, but don’t go away now, we haven’t finished, there’s a lot, a lot left to see.

WordPress or Apache redirects?

As I told you a moment ago, the Redirection plugin has the ability to make redirects in the Apache .htaccess file, and this is a possibility, because by default it makes them from the WordPress database.

The main difference between doing redirects in WordPress or in the Apache server is this:

  • WordPress redirects require database queries to be resolved in addition to using the caching system and are only performed after the WordPress loading sequence.
  • .htaccess redirects are done to the server, before it loads WordPress, your theme, plugins, etc.

Consequently, .htaccess redirects are always faster and better.

How to configure redirects via .htaccess in Redirection?

The Redirection plugin, by default, performs WordPress redirects, so to change this behavior you have to make 2 changes to your settings.

The first is to go through the options (as we saw above) and add the path of your .htaccess file to the box called “.htaccess of Apache”.

As you can see in the screenshot, the plugin tells you where the .htaccess file is, so you just have to copy the path, and add the file name.

In the previous example what you would have to enter in the box would be this: /home/customer/www/ .com/public_html/ /.htaccess

Now you should save the changes, but we are not finished.

The next step is to go to the “Groups” tab and edit the groups created to change the module, from WordPress to Apache.

From now on your redirects will be saved in the .htaccess file.

You can also save the redirects in a NginX redirect file if it’s your server. In this case there’s nothing to configure beforehand, just choose the Nginx module in the groups.

You can check that redirects are generated in your .htaccess file by looking for lines like the following:

# Created by Redirection
# Mon, 28 Sep 2020 14:36:11 +0000
# Redirection 4.8 -
<IfModule mod_rewrite.c>
RewriteRule ^seo/block-image/$ /seo/block-image/ [R=301,L]
RewriteRule ^seo/block-gallery/$ /seo/block-gallery/ [R=301,L]
# End of RedirectionCode language: PHP (php)

Note: Don’t be afraid to change WordPress module redirects to Apache, nothing is lost, Redirection transfers WordPress redirects to the .htaccess file automatically when the module group is changed.

How to set up automatic redirects in WordPress with Redirection

Would you like to have an automatic redirect created when you delete an entry or change a URL or the permanent links so that no traffic or SEO is lost?

Well, with Redirection you can do it, you don’t need any premium plugin to do it.

You only have to activate URL monitoring.

The first opportunity to activate it is in the configuration assistant as we already saw(the first checkmark)

But just in case, go through the Redirection options and make sure you have URL monitoring enabled on everything, like this:

From this point on, when you change a URL of an entry or page, or send something to the trash, automatic redirects will be created.

In the case of URL changes, the old URL is redirected to the new one, and when it is a deletion, a redirect to home page is created, which if you want you can modify later in the “Redirects” screen of the plugin settings, where you will see that they have been created automatically.

How to set up manual redirects with Redirection

If you need to make a redirect manually go to the redirect tab of the plugin, at the bottom you have the tool to create them.

In principle the basic procedure is simple, you only have to put the URL (relative, only the slug) of origin, and the URL (here complete) of destination.

If you want to choose the group to which it will be added (by default it will be the redirects group) and press the “Add redirect” button.

A permanent redirect (301) will be created that will direct all requests from the old URL to the new URL.

But I recommend that you get used to always activate the advanced options.

Three new and very interesting fields will appear:

  • Title: In case you want to describe the purpose of the redirect, which will be recorded as a comment in the redirect, for future reference. This is very useful in migrations or important URL changes.
  • Match: Here you have a series of possible rules that will be applied to the redirect, to make redirects according to language, IP, user agent, cookie, referrer, server, headers and more. This is great for conditional redirects, dependent on one of these values. When you activate something other than “URL only”, new fields will be displayed in which to fill in the conditional elements.
  • When matched: Here you can add another conditional element in case it matches the previously selected conditions. You can choose to redirect to a URL (default), to a random entry, to pass directly the URL, to mark as 404, or simply to do nothing. Every time you select one of these possibilities, the form will change to adapt to what you have selected.
  • with the HTTP code: By default, Redirection creates redirects of type 301 (permanent) but in any specific redirect you can choose another HTTP code, the possibilities are
    • 301 – Moved permanently
    • 302 – Found
    • 303 – See another one
    • 304 – Unmodified
    • 307 – Temporary redirect
    • 308 – Permanent redirect
    • 404 – Not found (if you chose it in the optional “When matched” parameter)

I think it is worthwhile to review the advanced options. Normally you won’t need them but it is important that you know they are there, so that you can appreciate the enormous potential of the plugin

Redirects through REGEX regular expressions?

I have overlooked – on purpose – to comment that besides URL redirects you can do them with some additional parameters, and more specifically, do REGEX redirects.

You can see the options by displaying the filter next to the source URL.

In addition to ignoring case or ignore whether the URL ends in a slash or not, which you can also define for all redirects in the general options, the relevant thing is that you can do redirects using regular expressions (REGEX).

If you select this option in the filter you will see that nothing seems to have changed, because the fields are the same, and you are right, what changes is the way to do the redirects.

Regular expression redirects are done by applying wildcards, which is tremendously useful, if not essential, when you have to make a big URL change on your site.

For example, imagine you’ve changed the permanent links from /%postname%/ to /%category%/%spostname%/.

You wouldn’t even think of starting a URL-to-RL permanent redirect, would you? By proxy you can, but no one in their right mind would consider it.

Here the redirects REGEX come into play, by means of regular expressions, or with wildcards.

In the previous example the redirect would be like in the following capture…

The possibilities of redirects through regular expressions are very powerful and offer great flexibility.

Some frequently used parameters are the following:

  • .* – Usually in parenthesis. The dot refers to any character and the asterisk to any amount.
  • $1 – Here it is indicated that what is captured in (.*) will appear
  • ^ – Tells the popular expression to apply only if there is a match at the beginning of the URL. This prevents matches from being generated with any part of the URL, which can sometimes cause an infinite redirect loop.

But there are more parameters. Here’s a good guide to getting started on regular expressions.

Examples of redirects using REGEX regular expressions

To make you understand, here are a few fairly common regular expressions you may need at some point:

  • Redirect from date and time to entry name:
    Source: ^/\d{4}/\d{2}/\d{2}/(.)
    Destination: /$1/
    Example: /2020/01/01/hello-world/ => /hello-world/
  • Redirect from date, time, name and category to entry name
    Source: ^/\d{4}/\d{2}/\d{2}/.?/(.)
    Destination: /$1/
    Example: /2020/01/01/category/general/hello-world/ => /hello-world/
  • Redirect all the contents of an old site to a new one
    Source: /(.)
    Example: =>
  • Remove index.php from the URL:
    Source: /index.php/(.)
    Destination: /$1/
    Example: =>
  • Remove .html from Blogspot pages:
    Source: ^/(.?).html$
    Destination: /$1/
    Example: =>
  • Redirect AMP pages to the original ones ( 😉 ):
    Source: (.*?)/amp/$
    Destination: /$1/
    Example: =>

As you can see from the examples, the possibilities are almost infinite, but above all it is an essential tool in cases of important redirections.

Other interesting tools of the Redirection plugin

Believe it or not we haven’t finished yet, this wonderful plugin incorporates more interesting tools worth mentioning … and use.

Site settings

This plugin settings page is especially dangerous, and you should only use it if you know EXACTLY what you are doing.

Any misconfigured settings could even prevent you from accessing your site again, leaving it useless, destroying your SEO, a disaster.

As you can see in the previous screenshot of the site settings you can create a complete redirect from one domain to another. Just enter the URL of the new domain in the empty box and a permanent redirect to the new domain will be created.

This is a setting you should only use if you are going to change your domain site, as a preliminary step just before making the DNS change.

In addition, you can also add domain aliases, so if you have a previous domain or sub-domain that you want to redirect to the current one, just add its URLs here.

Do I need to remind you that this is a mortal danger if you are not sure about it?

As you can see a little further down this settings screen you can also force the redirect from HTTP to HTTPS, in this case very interesting and useful, if you have an active SSL certificate and have not yet performed the redirect. You avoid having a plugin just to do this redirect or having to do it manually on your server.

You can also set up your preferred domain:

  • Do not set it, so all traffic will be resolved with the current settings.
  • Without WWW
  • With WWW

And, finally, you can add HTTP headers, a security plus to your website. The possibilities are:

  • Adding custom headers.
  • Adding headers with security presets.
  • Adding headers with CORS access control presets.

404 Error Log

You will also find a page where the plugin will display all the visits that have found a 404 error, allowing you to make quick redirects without leaving this page.

This is a testing website i have.

It is a fundamental tool for SEO, since it informs you of which 404 errors you are offering to visitors, showing you information such as the user agent, the referring URL and, if you want, even the IP.

Importer / Exporter

Last but not least, you have Redirection’s import and export tools.

As you can see in the previous screenshot there are 3 different sections.

The first one allows you to import redirects from CSV, JSON or plain text .htaccess files. Just drag and drop the file into the box and it will import them automatically.

Then you have the export tool, where you can choose between the following file formats:

  • JSON (full)
  • CSV (may require additional work)
  • .htaccess of Apache
  • NginX rewrite rules

For each format to download you can choose to export all or only the redirects (from Apache, WordPress or NginX), as well as view the generated files before downloading them.

Additionally, below you have a couple of buttons to export the redirect or 404 error logs in CSV format.

Finally, the tool called Plugin Importers detects whether your installation contains redirects created by other redirect or SEO plugins, but it doesn’t stop there.(Here it doesn’t show becasue this installation doesnt have those kind of plugins)

This tool also detects if there are old WordPress slugs in the database, and allows you to automatically create redirects to the current ones, a lifesaver in many occasions, especially on veteran sites.

What should I do if I cannot access my website?

As I warned you a little above, there are Redirection plugin settings that can completely break your website if you don’t know what you’re doing, so this guide wouldn’t be complete without showing you how to recover your website in case of a disaster due to a bad Redirection setup.

If you are unfortunate enough to be unable to access your site due to a misconfiguration of Redirection, it is urgent to completely disable the plugin.

How to disable Redirection

There are basically 3 ways to disable Redirection in case of problems, depending on the type of problem:

  • Create with your favorite text editor an empty file called redirection-disable.txt and upload it via FTP or from your hosting file manager to the /wp-content/plugins/redirection/redirection-disable.txt folder. Once this empty file is uploaded to the indicated path the plugin will continue to work but with the redirections disabled, allowing you to check them to find and disable or delete the one that caused the problem. When you finish fixing the mess, delete the redirection-disable.txt file.
  • If you simply want to completely disable the plugin you can add to the wp-config.php file the line define(REDIRECTION_DISABLE', true ); and save the changes.
  • But if none of the above works, by FTP or the hosting file manager rename the /wp-content/plugins/redirection/ folder to /wp-content/plugins/redirection.disabled/. Access your site, with the plugin already deactivated, make the necessary changes and you can rename the plugin folder and try to activate it again.

Well, that’s it, what did you think of this guide to using the Redirection plugin? Did you already know all its possibilities or has it helped you learn something new?

Read this post in Spanish: Guía avanzada de uso de Redirection, el mejor plugin WordPress para hacer redirecciones

How useful was this post?

Click on a smiley to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

1 thought on “Advanced Redirection User guide, the best WordPress plugin for making redirects”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top