How to set up a 301 redirect in WordPress

When 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’s also bad for the reading experience if they come up empty. You would also lose a lot of valuable backlinks from other websites if your page link breaks. So when you change a page link, you need to set up a 301 redirect rule that will automatically redirect Google and your readers to the new page location. How to set up a 301 redirect in WordPress.

Continue reading: What is WordPress and should you be using it?

QUICK RESPONSE

To set up a 301 redirect in WordPress easily and quickly, 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 a line of text.


SKIP TO KEY SECTIONS

When should a 301 redirect be used and when not?

signpost

You should use a 301 redirect if you want 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, Google and all human website traffic will return a 404 Page Not Found error. This is not good. A 301 ensures a smooth transition to the new page position – human visitors are unlikely to 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 changed permanently and they should stop indexing it. If you plan on going back to the old link in the future, then a 302 redirect is better. This tells Google that the redirect is temporary. Such temporary redirects can also be used to keep pages live while you maintain the website.

If you do a 301 redirect and then decide to go back to the old URL, it’s easily undone. However, if Google decides that the original redirect was permanent, it may take them quite a while to make the necessary changes to the old URL in the search rankings. In the meantime, you would potentially lose valuable traffic. So it is best to use the right forwarding right away.

Since a 301 is the most common type of redirect, we’ll focus solely on that in this article. But the following guide is the same if you opt for 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 located in the root folder and is usually hidden by the web host so you don’t accidentally delete it. If you do this, your website will be shut down. However, with an FTP program, you can easily unhide and open the file. Just remember to hide it again afterwards.

When you set up a redirect, it’s added to the .htaccess file so your site always remembers it. There are two ways to do this editing to the .htaccess file – either using a plugin or by editing the file directly. Both achieve the same end goal – many people, especially if they don’t want to mess with the .htaccess file directly – 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 look at editing the file directly for all the ruthless maniacs out there who enjoy living a dangerous life on the edge.

Using a plugin

Yoast Premium sets up 301 redirects

If you’re using Yoast’s $99 premium version, running 301 redirects is already built 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 active page, Yoast will automatically detect this and ask you if you want to set up a redirect.

However, not everyone has $99 a year under the sofa. So if you fall into this camp, you need a free plugin that does the same. However, free SEO plugins are a bit tricky as there are not many that do 301 redirects for free. Also, the free plugins that perform redirects are often not regularly maintained, so you should be very careful with them for security reasons.

301 Redirect WordPress Plugin

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

If you are setting it up for the first time, you will be guided through a setup wizard. Choose everything.

Set up redirect plugin

To set up a 301, go to Add new redirect and enter the old URL under Source URL. Enter the new URL below Target URL. Save and that’s it.

Redirect plugin set up 301

Editing the .htaccess file directly

cyberduck

If you don’t like using a plugin or would rather edit the .htaccess file directly, you can do it very easily.

  • Get an FTP program like FileZilla or Cyberduck. I highly recommend Cyberduck, even though they keep asking to donate to the developer.
  • Login to your website with your FTP credentials. You can get them from your web host if you don’t already have them.
  • Change to the root folder of your web server. The root folder is the first folder you go to when you log in .htaccess File should be at the top of the list. If not, look for the option in the FTP program to show hidden files. In Cyberduck it is under View->Show hidden files.
  • Right click on the .htaccess file and choose to edit it with a plain text Notepad file of your choice.

When you open the file you will see this above.

code

<IfModule mod_rewrite.c>
RewriteEngine On

Below that, you should then type:

code

Redirect 301 "https://www.domain.com/oldlink" "https://www.domain.com/newlink"

frequently asked Questions

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

This means you made a mistake in the 301 redirect. Reopen the .htaccess file and check the line you just typed.

No, nothing is permanent. If you later want to remove or change it, just open the .htaccess file and make the changes you want. However, it may take some time for Google to re-index the page and make the necessary updates in its own system.

It’s impossible to know for sure (the rules keep changing), but it looks like they won’t penalize you if you redirect to an exact identical copy of the original page. If you redirect to a less relevant page, you will find that your page will drop in rank.

No, that would be a 410 Content Deleted.

Leave a Reply

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