Whenever we need to change the path or the address of a web page or post and do not wish to lose the indexing that was achieved, we turn to a pretty common resource called a redirect.
A redirect is a trigger to a new path to an existing page's link, domain, or subdomain. By doing that, you can make sure that the old path does not lead you nowhere, for instance.
There are many ways to set up a redirect while using WordPress. In this tutorial, you will learn how to configure it using Redirection, a popular plugin that is used by the framework's community.
- To begin, install Redirection through the admin panel. Then, access your settings by going to Tools > Redirection:
- When accessing your settings for the first time, the system will require a configuration check. Just follow the steps and you will arrive at a screen such as this one:
Over here, we can add new redirects, configure a new record to obtain a response to a predefined page or import/export a list of redirects in CSV format, in case you have lots of links.
To configure a redirect, you must understand it can have two types:
There is the REGEX redirect type:
The term REGEX means regular expression, which is a sequence of characters that defines a search pattern. When you enable this option, the "Origin URL" and "Target URL" fields can be filled with regular expressions and can capture group references and variables such as $host and $scheme.
We usually employ these expressions whenever we have a large group of redirects to configure, like:
I'd like to redirect all my links to a new site by following this standard: site.com/product/”*” (* means the rest of the content) to product.site.com/$1 ($1 means where the redirected content will be added):
And then we have a common redirect, in which you type the content path and add the target URL to the appropriate field:
After you are done, just save the redirect so the rule can come into effect, and the specified path will now lead to the provided target.
Be careful with redirects
When configuring a redirect, you must be very careful with the content and values you add to the fields. That is because any incorrect changes might make you lose access to your site and even bring it down.
In addition, for your redirection to work like in the tutorial, the Redirection plugin must be activated on your WordPress panel.