An HTTP redirection is a magical thing. When you visit a URL with a redirection, your browser automatically jumps to a new address.
You’ve seen this before with URL shortener services like Bitly – instead of typing a long address, you type a short one. Your browser is automatically redirected to a different site, and it happens faster than you can blink.
HTTP redirections are powerful tools in SEO, and they have lots of other uses, too. Rank Math makes it easy for you to set up HTTP redirects – in this article, we show you how.
There are three places where you can set up a redirect – in the redirections screen, on the 404 Monitor screen, and in the editor screen.
We cover the URL redirection options for each of these screens in their respective articles.
Which Screen Should You Use?
If you decide to redirect one of your existing posts or pages, it makes sense to use the editor screen.
You can read how to do that in the editor screen article.
If you are getting a lot of 404 errors, it either means you have missing files, or people are clicking on broken links. We cover this in more detail in the 404 Tracker article.
If you want to create a new redirection, you can use the “Redirections screen.”
On the redirections screen, you can choose any URL to redirect. You don’t need an existing post or page at that address, and it doesn’t have to follow the format of your pages and posts.
The rest of this article covers the redirections screen.
You can find the redirections in Rank Math’s Sub Menu:
When you click on the link, the following screen appears:
As you can see, it’s a very simple interface. Of course, we don’t have any redirections set up yet! Let’s fix that now.
Click on the button that says “Add New”:
A form will appear at the top of the list:
Here are the various options that you need to consider when setting up a redirect.
- Source URL
- Source URL Match Type
- Destination URL
- Redirection Type
The Source URL is where you type the URL (or URLs) you want to redirect from, along with the destination URL and type of redirect.
When you write the “from” URL, you don’t need to write the full URL (with the http:// protocol and the domain name). Just write the address from the document root (the first “/” after your domain name).
For instance, instead of writing this:
… write this:
The destination URL is the place where visitors and search engines will be sent.
You’ll not always redirect just one URL. More times than often, you’ll need to redirect a bunch of different URLs to a new address. The match type field is where you control how that happens. Here are all the options in the match type field.
Let’s discuss each of the types.
Exact match is pretty self-explanatory. It matches the URL that user lands on to the exact URL that you placed in the source URL and redirects only if both the fields are an exact match. For example, if the URL the user visits is
yoursite.com/cat/apple-cider-vinegar/ then the source URL must say
/apple-cider-vinegar for the redirection to work. Even the slightest change will cause the redirection to fail.
The Contains match type field will cause all the URLs to redirect that contain a specific term. Let’s say that you have many posts on your website with “oranges” in the URL. If for some reason, you want to redirect them all to a new URL, all you have to do is enter “oranges” in the Source URL field, choose Contains as the match type and enter a destination URL. All the URLs on your website with the word “oranges” will then be redirected to the destination URL.
You might be thinking about how would you use this match type on a day to day basis. Let us give you a more practical example to show you how powerful this is.
Imagine that you have a blog about Celebrity Lifestyle. You have hundreds of celebrity posts which talk about their life, what they do, etc. You wake up one day and find out that Justin Bieber just got married. You write a post about it and quickly use the Contains match feature to redirect all Justin Bieber posts to the new wedding post. As a result, your blog soars in popularity and gets tons of shares, views, and maybe links. Once the hype dies, you can disable the redirect.
PS: This technique is used by the biggest publications in the world, especially when major news breaks out. The more you know.
The Start With match type will redirect all URLs that start with the keyword in the Source URL field. For example, if you enter “bacon” in the source URL, this will happen.
- /bacon-and-eggs/ – Will match and redirect
- /bacon-for-breakfast/ – Will match and redirect
- /why-is-bacon-delicious/ – Will not match and not redirect
Similar to Start With, the End with match type will redirect all URLs that end with the keyword in the source URL field. For example, if you enter “orange” in the source URL, this will happen.
- /how-to-make-orange-juice/ – Will not match and not redirect
- /how-to-peel-an-orange/ – Will match and redirect
- /apple-juice-vs-orange-juice/ – Will not match and not redirect
There’s a “regex” option under the “From” URL box. Regex stands for regular expressions – they’re a very powerful pattern matching tool. Regular expressions allow you to write a pattern, and Rank Math will redirect any URL that matches the pattern.
For instance, you might want to match any URL for pages that start with an “a” and end with a “z”. You can use an expression like this:
This pattern will match URLs like:
It won’t match a URL like this:
Regular expressions are a great tool because you can match thousands of URLs with a single line. But they can also be dangerous – if you make a mistake, they will either not work, or match too many URLs.
A bad regular expression could make whole sections of your site “disappear”!
If you’ve never used regular expressions before, you should read through a tutorial or a book first. Get some practice and confidence before you try them in Rank Math. You can test your regular expressions with this online editor before you use them live on your site.
There are 2 redirect codes you can use – 301 and 302. These are the HTTP response codes that are sent from the server.
In HTTP, every server response has a code number. For instance, when a server sends content to a browser (or spider), it uses a “200” code – that means the resource was found.
Codes that start with a “3” are redirects. They were originally designed to make it easy to move files on your server (or even between servers) without breaking your links.
A “301” code means the old URL has permanently moved to a new address. It’s never coming back.
A “302” code means the move is temporary. It may come back to the old address in the future.
To human eyes, they both act the same way. When the browser asks the server for a URL, it gets a redirect code. The server sends the code and a new URL. The browser instantly loads the new page.
It works the same way for 301 redirects and 302 redirects. So why choose one over the other?
The answer is search engines. Search engines examine the redirect code and make decisions based on the code number.
If a search engine sees a 301 code, it knows the move is permanent. Google will update its links database, passing all the PageRank to the new URL. This works with old links and even new ones – Google simply understands that the old URL and the new one are links to the same page.
A 302 code is only a temporary move, so Google won’t send the link juice to the new URL.
If you are redirecting for a very short period of time, and you want to bring the old URL back (with its original Google ranking), use a 302 code. If the redirect is permanent, use a 301 code.
For instance, if you decide to change the URL of one of your articles, you should create a 301 (permanent) redirect from the old URL to the new one. If you are redirecting a broken link, you should also use a 301 redirect.
There are countless ways to use these redirects, so we can’t list them all here! So just consider how you want Google to treat the redirection. If it’s a permanent move, use the 301 option. Otherwise, use a 302.
You can choose any target URL – it can be a page on your site or a page on another site. It doesn’t even have to be an HTML page. You can redirect your users to a static file, like a PDF, image, video, CSS file – anything you want.
Finally, you can activate the redirection immediately, or create it in “inactive mode”. When a redirection is in “inactive mode”, it doesn’t do anything. You have to activate it to make it work.
You can tell the redirection is inactive because it’s displayed in gray:
It’s easy to activate a redirection, just click on the “activate” link:
Here’s a quick example – the ever-useful redirect to Google! In this case, if our user visits http://www.our-site.com/go-to-google, the server will immediately redirect them to Google.
Notice that we used the 302 redirect code – this is a temporary redirect, and it won’t send any “link juice” to Google’s home page.
To save the redirection, just click on “Create”.
Rank Math tracks how many times each redirection has been accessed – humans and bots are counted.
This is very useful to get feedback on where your traffic is flowing. For instance, if you’re redirecting to an external site, you probably can’t access their server logs. But Rank Math will tell you how many people clicked the link.
You can see the redirection statistics in the last two columns of the Redirections screen:
The “last accessed” column gives you the most recent date and time when someone clicked on the redirect. It counts robots as well as human visitors.
The “hits” column gives you the total number of times the redirect has been accessed since you set it up.
Backing up Your Redirections
Just as you back up your website and the important data on your computer, it is also important to back up your redirects. Losing redirects without having a backup is the stuff webmaster’s nightmares are made of. Don’t put your website at risk, back up your redirects.
Rank Math not only makes it effortless to redirect your backups, but it also supports 1-click backups for Apache and Nginx servers. Let’s see how to create a backup.
On the top of the page, you’ll see 2 buttons to backup your settings. Click the button for your server to create a backup. For this example, we are going to create a backup for Apache.
Rank Math will immediately open a dialog box. Choose a location for the redirect file, then click Save.
You’ll notice that the redirect file also has a timestamp which will help you identify and manage your files better.
Why Use Redirections?
So, we’ve shown you how easy it is to set up redirections through the “Redirections” screen. There are a couple of other places where you can make them – in the 404 tracker and the page/post editor screens.
You may wonder why you should bother with HTTP redirections – there are lots of good reasons. Read this article to learn more about how redirections can help you in SEO and in general.
Was this article helpful?
Still need help?
Submit Your Question
Please give us the details, our support team will ge back to you.