BACK TO TOP

How to Create 301 Redirect in WordPress

How to Create 301 Redirects in WordPress

Have you ever clicked on a link only to be greeted by a 404 page informing you the content you’re looking for has been moved? It’s annoying, right? Which is exactly why you want to make sure this never happens to your website visitors.

If you ever change your website URL, or even the URL of a single page on your site, you can ensure your visitors still have access to that content by simply redirecting them to the new URL. And that’s precisely what 301 redirects are for.

In this article, we’ll show you how to create 301 redirects in WordPress. The subjects we’ll talk about include:

First, let’s take a look at what the “301” in 301 redirect actually means.

What Are HTTP Status Codes

To put it simply, 301 is an HTTP response status code that indicates the page we’ve requested has been permanently moved elsewhere. And 301 is just one of many HTTP responses that tell us what’s happening with an URL.

You see, when you want to access a certain page, your browser sends a request to that website’s server. And there are five classes of HTTP response status codes a server can send to a browser: 1xx (informational response), 2xx (successful), 3xx (redirection), 4xx (client error), 5xx (server error).

The fastest way to check HTTP codes on your own website is by pressing the F12 button and then checking the Network tab.

For instance, if everything’s working like a charm, a server will respond with a 2xx HTTP status code, which means that the desired content will successfully be served to the visitor.

HTTP Status Code

As for the 3xx HTTP response codes, they signify a page has been removed and that users will be redirected to the new URL. There are several types of redirects. The most commonly used are:

  • 301 – moved permanently
  • 302 – moved temporarily, e.g. for A/B testing
  • 307 – moved temporarily, e.g. during website maintenance
  • Meta Refresh – a redirect that automatically reloads the current page after a certain time period; the following message is an example of a meta refresh redirect – If you are not redirected in five seconds, click here.

Why You Need 301 Redirects on Your WordPress Website

If you decide to use a 301 redirect, all the existing traffic will be seamlessly transferred from the old URL to the new one. You won’t lose any leads or potential conversions. In fact, in 2016 one of Google’s webmasters, Gary Illyes, confirmed that 3xx redirects don’t lose PageRank, which means they’re just as powerful as the original page or a post.

Some of the most common reasons why you may want to use a 301 redirect are the following:

  • You want to delete a page or a post
  • You’d like to change permalinks
  • You want to migrate your website from HTTP to HTTPS
  • Or you’re considering moving your website to a new domain

How Long Should You Keep a 301 Redirect Active?

Google’s webmaster John Muller discussed the question of how long to keep a 301 redirect active during a hangout he did back in 2015. He said that theoretically, you could keep a 301 redirect forever since that redirection in itself is permanent. But it’s worth remembering that it takes a while for Google (and other search engines) to recognize a website has been moved. Mr Muller’s advice is to keep the redirect around for at least a year or possibly even a bit longer, depending on your circumstances. In case you remove the 301 redirect sooner than that, Google may continue to show the old URL, especially if external links to it exist on the web.

How to Set Up 301 Redirects in WordPress With .htaccess

The .htaccess file is a configuration file, and one of the core files of a WordPress website. Needless to say, any changes you make to the file should be done with the utmost caution.

The .htaccess file tells servers how to handle certain things on your website. A website can have several .htaccess files, but the main one that we’re interested in is located in the root or a central directory of your WordPress website.

To find a .htaccess file on your site and access it, you need to login to your server using an FTP client. If you’re not sure how to do this, check out our FTP beginners guide. A dot next to the name of the file indicates that the file is hidden. Please note that this file is hidden by default. To find it, edit the settings in your FTP client so that it displays hidden files.

Now that you can see the main .htaccess file, before you make any edits, make sure to back up its content. To do it, right-click on the file and select Download (depending on your FTP client, you may see a different option, e.g. Add to download list, etc.). You can also copy the file and paste it on your computer.

To start making changes to the file, once again, right-click on it and select Edit.

HTTP Status Code Edit

Redirect a Page or a Post to Another Page or a Post

First, let’s see how to create a 301 redirect of the post or a page on the same domain. In such cases, this is the code you need to add to your .htaccess file:

Redirect 301 old-url new-url

Add the old URL first, and then the new one. You can make as many redirects as you like, simply copy this code and add relevant URLs.

Redirect Your Website from an Old to a New Domain

When you want to move your website to a new domain and create a 301 redirect for that, you need to edit the .htaccess file of the old domain using the following code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
RewriteRule (.*)$ https://www.newdomain.com/$1 [R=301,L]

Just make sure to change the URLs to match your old and new domains.

Redirect from HTTP to HTTPS

To keep your website secure and to protect your users, you should run it under HTTPS and add a valid SSL certificate to it. If you want to migrate a website from HTTP to HTTPS, you also have to redirect the traffic from the former to the latter. The best way to do it is by using a 301 redirect, as advised in this video, again, by Google’s John Mueller. To create a 301 redirect, add the following code to the main .htaccess file:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Again, just change the URL to match your own.

Qode WordPress Themes: Top Picks
Bridge WordPress Theme Banner
Bridge

Creative Multi-Purpose WordPress Theme

Stockholm WordPress Theme
Stockholm

A Genuinely Multi-Concept Theme

Startit WordPress Theme
Startit

Fresh Startup Business Theme

Biagiott banneri
Biagiotti

Beauty and Cosmetics Shop

How to Create 301 Redirects Using Plugins

If you’re not comfortable with altering the main .htaccess file, you can create 301 redirects by using a WordPress redirection plugin. We bring you 5 plugins we believe work best.

1. Redirection

Redirection WordPress plugin is surely the most popular on the list, with over 1 million active installations. It’s been around for more than 10 years, and it’s a great choice for creating 301 redirections. This plugin lets you track 404 errors on your website, and among many useful options, it also includes the configurable logging option. Configurable logging allows you to keep an eye on redirects that are happening on your website, as well as to get the info about your visitors, such as their location, the browser they used, etc.

Once the installation process is complete, activate the plugin. Next, go to Tools > Redirection.

Redirection Plugin

Here, you can enter the source and the target URL, and create redirections as per your requirements.

Redirection Plugin Settings

2. Simple 301 Redirects

The Simple 301 Redirects plugin has over 300,000 active installations and is incredibly easy to use.

To create a redirect (once you’ve installed and activated the plugin), go to Settings > 301 Redirects.

Simple 301 Redirect Plugin

There are two boxes – one for the old URL, and another one for the new URL.

Simple 301 Redirect Plugin Settings

If you wish, you can also use Wildcards redirects. To activate them, simply tick the box below the URLs and click on Save Changes.

2. Rank Math

Rank Math is a great SEO plugin that can also be used to effortlessly create redirects.

For starters, head over to Rank Math > Redirections.

Rank Math Redirection

If you can’t see the option in the submenu, go to Rank Math > Dashboard and enable the Redirections option.

Turn on Rank Math reddirection

Then, select Add New and set up the new redirection.

New redirection 301

This plugin is a great choice for creating redirects the easy way, but you can also use Rank Math as your SEO plugin.

4. Quick Page/Post Redirect Plugin

As its name suggests, the Quick Page/Post Redirect Plugin lets its users create redirects fast. At the moment, there are more than 200,000 active installations of this plugin.

When you install and activate it, the plugin will appear in your admin menu. Hover over it to see the options it includes.

Quick Page Post Redirect Plugin

To add new redirects, click on Quick Redirects. Then paste the old and the new URLs. When you’re done, click on Add New Redirects.

Quick Redirects Add New

5. Safe Redirect Manager

With more than 50k active installations, the Safe Redirect Manager is the final redirect plugin we’ll feature on our list.

Upon installing and activating the plugin, go to Tools > Safe Redirect Manager.

Safe Redirect Manager Plugin

Click on it and then on Create Redirect Rule at the top of the page.

Safe Redirect Manager Settings

After that, enter appropriate URLs in the Redirect From and Redirect To fields.

Safe Redirect Manager Settings

Under Redirect Settings > HTTP Status Code select 301 Moved permanently.

Safe Redirect Manager Settings

When you’re done, press Publish for changes to take effect.

To Sum Things Up

301 redirects are incredibly useful and can positively impact the browsing experience of your users. People won’t be too happy if they can’t find the web page they’re looking for, which is why it’s in your best interest to redirect them to a valid URL. Setting up 301 redirects is also a great way of ensuring that link equity is transferred from an old to a new page. That’s why we wanted to show you how to create 301 redirect pages in WordPress, so you can get your users to the right place.

Don’t go overboard with redirects, though. Your top-level domain shouldn’t have more than one 3xx page. Use them only when necessary, since they may increase the page load time, as well as negatively impact your user experience.

Post your comment

Comments0