How to set up redirects in WordPress. Image depicts the corner of a laptop. There is a sticky note on it that reads Error 404

WordPress Redirects: a Complete Guide

If you’ve redesigned your WordPress website or made revisions to its permalink structure, chances are that many of your URLs have changed. This is an issue for search engines and users alike. 

Fortunately, WordPress redirects offer a simple solution. When you use a redirect, your visitors won’t be negatively impacted, and you’ll be able to keep your search engine rankings intact.

On this page, we’ll talk about what WordPress redirects are and how to implement them. Let’s dive in!

What is a page redirect?

A page redirect is a set of rules telling a browser to forward visitors from the link they clicked on to a different page. There are two outcomes for your end users when you redirect a page. They will either see a message that lets them know they are being redirected or simply be forwarded without being notified.

If you’ve changed your domain, made updates to your permalinks, or redesigned your site, you’ll need to add redirects so your pre-existing content is still accessible to readers and search engines. Think of it this way: When you move to a new home, you must contact the post office and have your mail forwarded to your new address. Redirects work the same way, except instead of forwarding your mail, you forward users to a new web page.

When & why should you redirect a page?

There are various reasons you may want to redirect URLs on your site. Some of the most common include:

  • A specific page is no longer relevant.
  • The page’s URL is changing.
  • You’re moving or deleting content.
  • You’re moving your domain from HTTP to HTTPS.
  • You’re working on using a different domain or changing your original domain name
  • You want to redirect an old URL to reclaim a broken link

In addition, redirects can help you ensure that if a page is broken or missing, users will be sent along to your site’s other content without interruption.

Why should you implement a redirect?

Types of redirects

Since there are quite a few ways to use a redirect, it makes sense that there are also several different types. Let’s take a look at the most common redirect methods you might need to use. 

There are various types of redirects you can use, so it’s important to know the differences between them. Let’s review some of the most basic types of redirects.

  • 301 Permanent Redirect. This is the redirect you’ll want to use if you are permanently moving or deleting a page. You may use this if you move your website from one URL to another or switch it to a new hosting service. This will guide visitors to the new URL and help you maintain a respectable page rank. This is the most SEO-friendly redirect for a broken link.
  • 302 Temporary Redirect. The 302 redirect is a temporary redirect that should be used with caution and tested for browser compatibility. Essentially, this redirect tells the user that the file they are looking for exists, but for some reason it’s not loading properly. Users are then offered an alternative option. For long-term use, these redirects can carry SEO penalties. However, you may wish to use them for staging environments and other temporary sites.
  • 303 See Other.  In terms of security, the 303 redirect is pretty important. It is used to replace the 302 redirect when problems arise. This type of redirect prevents users from submitting the same information more than once. Once they submit their information, they’ll be redirected to a different page. You can also prevent bookmarking or refreshing sensitive data such as credit card information. This is intended to prevent users from mistakes such as accidentally purchasing the same item twice.
  • 307. This redirect is nearly identical in functionality and purpose to the 303 redirect. The difference lies in how it sends and receives information. The 307 uses only one data exchange, and is a true temporary redirect. On the other hand, a 303 redirect employs two methods, and offers the ‘see other’ response
  • 308. Like the 301 redirect, this is a permanent redirect. It’s used when a file location has changed. The difference between the two is that a 301 can change the HyperText Transfer Protocol (HTTP) method from POST to GET, while 308 can only use the POST method. 
  • 404 Not Found. This redirects any broken or missing link to another page, such as a 404 error page or your site’s home page. This enables users to keep browsing your site even if they try to access a missing page.
  • HTTP to HTTPS Redirect. An HTTPS URL has advantages over an HTTP URL, both in terms of security and SEO. To force browsers to display the HTTPS version of your pages, however, you’ll need to set up a redirect.

Some of these redirect types are more common than others, but all of them have their uses. Understanding how each redirect performs can help you employ the best one for your specific scenario. Setting them up by hand can be tricky, though, which is where plugins come into play.

How to create a 301 redirect in WordPress Using .htaccess

WordPress offers various methods for page redirection. You can use a plugin or change your site’s .htaccess file. The method you choose will depend on the type of redirect you need, your hosting provider’s settings, and your comfort level with making changes to a core file.

As we covered earlier, a 301 redirect is used to permanently forward one URL to another, unlike 302 redirects (which are temporary). This means that search engines will default to the page at the new location, and index it appropriately. This type of redirect prevents your site from losing search engine rankings. Let’s break down a few steps you’ll need in order to take this approach. 

Step 1: Verify Your Web Host’s .htaccess Editing Rules

The .htaccess file is a configuration file that tells your server how to display pages from the WordPress root directory. You’ll need to check with your hosting provider before making changes to .htaccess, as there may be rules about what alterations you can make. If you have a plan here at WP Engine, we recommend using our Redirect Rules tool.

Step 2: Make a backup of your site and download your .htaccess file

To create a 301 redirect in .htaccess, you will need to use a File Transfer Protocol (FTP) client to access the file on your server. We recommend FileZilla. Before you get started, you’ll also want to make sure you have a backup of your site in place.

Then, use FileZilla to navigate to your site’s root directory:

From there, download your .htaccess file. You’ll want to create a copy, in case you make a mistake and need to restore the original. Then at the top of the file, add the following line:

Redirect 301 /current-page.html http://www.yoursite.com/new-page/

This redirect will change your URLs from http://www.yoursite.com/current-page to http://www.yoursite.com/new-page (you’ll need to replace the placeholders with your site’s information). When adding your redirects, remember that you can only have one per line in the .htaccess file.

How to redirect a page with a WordPress plugin

If you’re hesitant about messing around with your core website files, you may want to consider using a plugin to do so. We’ll go over several different plugin options later in greater detail. However, to give you a quick overview of how to set up a redirect with a plugin, we’ll use the Redirection plugin as an example:

Your first step will be to install and activate the plugin in your WordPress dashboard. Once you’ve done that, you’ll need to click through a few items in its Basic Setup process.

Once you’ve clicked through these steps, you’ll be taken to the Redirection plugin Options page.

From the Options page you can choose between several different features. Let’s first click on the Redirects link, and see how to add a new redirection to your website.

Similar to adding a new post, you can click Add New on the Redirection management page and fill in a bit of information about your redirect. This includes your Source URL and Target URL. You’ll also be able to define how you want the redirect to handle the parameters you set and assign it to any redirection Groups you’ve created. 

Once you’ve completed filling in these fields, you can click on Add Redirect as seen in the above image. Then you’ll be all set!

WordPress redirect plugins

As we mentioned, the WordPress Plugin Directory offers many plugins for adding redirects to your site.

When choosing a plugin for this purpose, be sure to research each one to make sure it’s well reviewed, widely used, and actively updated. Below, we’ll recommend some plugins that can help with each redirect scenario.

1. Redirection

This plugin is helpful for beginners, and can be used to forward any URL easily. Since we used Redirection in our previous example, you already know what the interface looks like. It’s important to know that this plugin in particular is focused on managing 301 redirects and keeping track of 404 errors.

Additionally, you can use Redirection to create redirects based on certain conditions, such as a user’s login status or IP address. This is a truly free plugin with no premium upgrade, so the features you get are the only ones they offer. However, if you need to manage other kinds of redirects, you might need to investigate another option. 

2. Safe Redirect Manager

The Safe Redirect Manager plugin is a very straightforward and barebones approach to creating redirects. You’ll access the manager through your Tools menu in WordPress, and simply provide information about where the redirect is from and where it’s going. You’ll also be able to set the HTTP status code for the kind of redirect you want to use. 

While this plugin can be used for large-scale redirects, you might want to test it out before implementing it across a lot of pages. Reviews are good, but there is some indication that it might struggle a little at an enterprise level. With that being said, this is a well-supported and frequently downloaded plugin that can help you set up a redirect very quickly. 

3. 301 Redirects – Easy Redirect Manager

The 301 Redirects – Easy Redirect Manager plugin is a free option designed to help you manage both 301 and 302 redirects. This can come in handy if you’ve reorganized an existing website, or are just starting out. Additionally, if you have content that expires, this can save your users from running into 404 errors. 

Another benefit this plugin offers is that you can create custom URLs for your redirect destinations. You can also choose to redirect almost all of the WordPress content types, including categories and archives, and access helpful stats about the amount of redirection being used on your website.

4. Yoast SEO

The Yoast SEO plugin’s premium version comes with a Redirect Manager, which has plenty of useful options for page redirects. When you delete a post or page, this tool automatically asks you where you’d like to redirect its old link to and what kind of redirect you’d like to use (temporary or permanent).

On the downside, Yoast SEO can be somewhat costly, at $89 per month for one site. However, Yoast SEO’s other excellent features can make it a valuable investment for many WordPress users.

What Is a server-side redirect?

There are certain situations when you’ll need to place a 301 redirect at the server level so that it can be enforced across the entire website. This technique is most commonly used when redirecting a site from HTTP to HTTPS, or from a www to a non-www domain.

How to redirect HTTP to HTTPS in WordPress

If you’ve installed an SSL certificate and successfully migrated your site to its new HTTPS domain, you’ll still need to create a server-side redirect. First, you’ll need to locate and download your site’s .htaccess file. Once there, add the following code at the top of the page:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]

This code changes every URL under your previous domain to a secure counterpart. If you’d prefer to use a plugin to do this, we recommend Really Simple SSL.

This plugin automatically detects your site’s settings, and then configures them to run over HTTPS. As long as you have a valid SSL certificate, it will take care of the rest for you.

Once you install and activate the plugin, you’ll get a notice asking you to enable SSL. Click the button, and log back into your account. That’s it!

WWW to non-WWW redirection

To redirect your pages to non-www URLs, you’ll need to apply the change at the full-site level. This redirect helps you avoid page duplication and poor user experience. To redirect www to non-www in your .htaccess file, you’ll need to enter the following lines at the top:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

www to non-www redirect

If you’re looking for a plugin that can help you do this, we again recommend Really Simple SSL. However, there’s also a WP Rocket helper plugin available through GitHub that is highly recommended by the developer community. This plugin enables you to redirect www to non-www and vice versa, by adding the correct code for you.

How to redirect a domain in WordPress

If you’re moving your WordPress site to an entirely new domain, you’ll need to perform a domain redirect to avoid losing your content’s SEO. These instructions assume that you’ve backed up your site and moved it to its new domain.

To perform this redirect, open up your .htaccess file, and add this code to the top:

#Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.newsite.COM/$1 [R=301,L]

Use your new domain in place of newsite.com, and then save the file. You can also use any of the above-mentioned plugins to accomplish this task, as long as you activate it on your old site.

How to minimize redirects in WordPress

While there are some legitimate and necessary uses for redirects, it’s also a good practice to minimize the need for them wherever possible. This is especially true if the redirect slows down your page loading times, as most web users expect pages to load in two seconds or less.

If a user encounters a redirect, they might immediately think they’ve gone off course and leave your website altogether. For this reason, it’s best to not link your content to known redirects, as it might create a frustrating redirect loop. If you’ve recently completed a major overhaul of your website, you can use the Redirection plugin to monitor, log, and fix redirect errors that might be causing problems. 

Keep your website on track with WP Engine

If you need any help configuring redirects on your WordPress site, don’t hesitate to contact us. WP Engine offers top resources for developers and can help you create an incredible digital experience for your own customers. We have several developer resources as well and offer plans that are suitable for a wide variety of needs

Get started

Build faster, protect your brand, and grow your business with a WordPress platform built to power remarkable online experiences.