How to set up a 301 redirect in WordPress

How to set up a 301 redirect in WordPress


If you have a website, the last thing you want is a 404 error page when a page link cannot be found. Not only is it bad for your Google search rankings, but it is also bad for the reader experience if they walk away empty-handed. You would also lose a lot of valuable backlinks from other sites if your page link breaks. So if you change a page link, you need to set up a 301 redirect rule which will automatically redirect Google and your readers to the page’s new location. Here’s how to set up a 301 redirect in WordPress.

Read more: What is WordPress, and should you use it?


To set up a 301 redirect in WordPress the easy and fast way, use a plugin, of which there are many in the WordPress plugins directory. Alternatively, you can edit the .htaccess file on your website server with one line of text.


When to use and not use a 301 redirect


You should use a 301 redirect when you plan to change the link (URL) of a live page to another link. If you change the link and don’t set up a 301 redirect, then Google and any human site traffic will encounter a 404 page not found error. This is not good. A 301 ensures a smooth transition to the new page location — it’s likely that any human visitors won’t even notice the change in the page link.

However, there may be reasons why a 301 redirect is not a good idea. A 301 tells Google that the link has been permanently changed and they should stop indexing it. If you plan to return to the old link in the future, then a 302 redirect is better. This tells Google that the redirection is merely temporary. Such temporary redirects can also be used to keep pages live while you are doing site maintenance.

If you do a 301 redirect, and subsequently decide to go back to the old URL, it can easily be reversed. But if Google thinks the original redirection was permanent, it could take quite a while for them to make the necessary changes back to the old URL in the search rankings. In the meantime, you would potentially be losing valuable traffic. So it’s best to use the right redirection in the first place.

Since a 301 is the most common type of redirect, we will focus solely on that in this article. But the following how-to is the same if you decide to do a 302 instead.

How to set up a 301 redirect in WordPress

htaccess file ftp

In your website server files, there is a text file called .htaccess. It’s in the root folder and is usually hidden by the web host, so you don’t accidentally delete it. If you do, your site will go down. Using an FTP program, though, you can easily unhide the file and open it. Just remember to hide it again afterward.

When you set up a redirect, it is added to the .htaccess file, so your website always remembers it. There are two ways to make that edit to the .htaccess file — either by using a plugin or by editing the file directly. Both accomplish the same end goal — many people, especially if they don’t want to mess directly with the .htaccess file — will find it more convenient and easier to let a plugin do the heavy lifting for them. So we’ll cover that first. Then we’ll look at editing the file directly for all you reckless maniacs out there who like to live life dangerously on the edge.

Using a plugin

yoast premium set up 301 redirect

If you use the premium $99 version of Yoast, then doing 301 redirects is already baked in. The process is extremely simple. Enter the old URL and the new URL, and click Add Redirect. If you change the URL to an already live page, Yoast will automatically detect that and ask you if you want to set up a redirect.

However, not everybody has $99 a year lying around under the sofa. So if you fall into that camp, you’ll need a free plugin that accomplishes the same thing. However, free SEO plugins are a bit difficult because there are not many of them around that do 301 redirections for free. Plus, the free plugins that do redirections are often not maintained regularly, so from a security perspective, you should be very wary of them.

301 redirect wordpress plugin

Saying that, there is one called Redirection, which is maintained more or less regularly and works as advertised. It’s been installed more than two million times and has a WordPress user rating of 4.5 out of 5.

When you set it up for the first time, it will take you through a setup wizard. Select everything.

redirection plugin setup

To set up a 301, go to Add new redirection and put the old URL under Source URL. Put the new URL under Target URL. Save, and that’s it.

redirect plugin set up 301

Editing the .htaccess file directly


If using a plugin doesn’t appeal, or you’d rather just edit the .htaccess file directly, then that’s very easy to do.

  • Get an FTP program such as FileZilla or Cyberduck. I highly recommend Cyberduck, even if it constantly asks you to donate to the developer.
  • Log into your site using your FTP details. You can get them from your web host if you don’t already know them.
  • Go to the root folder of your web server. The root folder is the first folder you come to when you log in. The .htaccess file should be there right at the top of the list. If not, find the option in the FTP program to reveal hidden files. In Cyberduck, it’s under View–>Show Hidden Files.
  • Right-click on the .htaccess file and select to edit it with a plaintext notepad file of your choice.

When you open the file, you will see this at the top.


<IfModule mod_rewrite.c>
RewriteEngine On

Underneath, you should then type:


Redirect 301 "" ""


A 301 is when the page in question has been permanently moved to a new URL. A 302 is when the page is being moved temporarily and will soon be changed back to the original URL.

This means you have made an error in the 301 redirect. Reopen the .htaccess file and check the line you just typed.

No, nothing is permanent. If you wish to remove it or amend it later, simply open the .htaccess file and make your desired changes. It may take some time for Google to reindex the page and make the necessary updates in their own system, though.

It’s impossible to know for sure (the rules change all the time), but it looks as if they will not penalize you if you redirect to an exact identical copy of the original page. If you redirect to a less relevant page, then you will start to see your page drop in rank.

No, that would be a 410 Content Deleted.


Source link