A 301 redirect is like a map that will take your website’s visitors from a page or post that no longer exists to one that does.
Imagine trying to get your groceries delivered, but the map app used by the driver stops at the end of your street and doesn’t take them all the way to your house. If your delivery driver has to stop at all the houses on your street to find you, then your popsicles will be melted. Or worse, he’ll take your groceries and go back to the store. A 301 redirect completes the journey to the correct destination.
In this guide to 301 redirects, we’ll cover everything you need to know about 301 redirects for your WordPress website, including seven things you need to know about 301 redirects and how to create a 301 redirect in WordPress.
What Is a 301 Redirect?
What is a 301 redirect? In a nutshell, a 301 redirect takes a user from an old URL to a new URL that replaces the old one that no longer exists.
Specifically, the 301 redirect status code indicates that whatever page the user is trying to access on a website or blog has been permanently moved to a new URL. In other words, the URL they used is an old URL and has been updated.
With a 301 redirect in place, a user will visit the updated URL when they try to access a URL that no longer exits. Unless the user has configured their browser to block redirects (high-security configurations usually do this), they’ll visit the updated URL instead.
In geek-speak, the 300-series of HTTP (Hypertext Transfer Protocol) status codes is used to show that a redirect should occur for various reasons.
The main reason a WordPress site would utilize a 301 redirect is to control how the site is accessed. We’ll take a look at the mechanics behind these redirects, how to create a 301 redirect in WordPress, and why you should make one.
7 Things to Know About 301 Redirects
When it comes to understanding 301 redirects, here are a few important (technical and non-technical) things to know.
- Plan to create a 301 redirect any time you delete a post or page on your website or blog. Whenever you delete a post or page on your website or blog, you need to think about which post or page should replace it. That’s where 301 redirects come in.
- A 301 redirect helps you avoid 404s. A 404 is what happens when you delete a post or page and don’t create a 301 redirect to a new post or page. As a best practice for a variety of reasons, 404s (also known as “page not found”), should be avoided at all costs.
- Major search engine providers recommend that you immediately add a 301 redirect when changing the URL of a page or post. This way, their search engines can track the changes and keep their results to your site up-to-date.
- There are highly technical ways to create 301 redirects or you can use a tool like a WordPress plugin. 301 redirects can be added to your website in a variety of ways, making the process more simple for the average user (more on that later).
- 301 redirects should only be used if the URL is public and not due to be changed anytime soon. This can also impact your SEO rankings, so watch out.
- Beware too many 301 redirects. You can also get pinged with lower SEO scores if you have multiple redirects. For example, if a URL has changed multiple times, you might have a 301 redirect for each one. Oops.
- Generally, when a client receives a 301 response, their bookmark to that URL will automatically be updated to the new one. That’s good news.
A few more technical things to note:
- 301 redirects can be used for making a 301 redirect is to make the “www” before a URL optional. Servers are often configured to insert a “www” if a user or link doesn’t supply it.
- A 301 redirect can also accomplish a change from “http://” before a URL to “https://”. If you’re finally moving your WordPress site to HTTPS (which is highly recommended!), 301 redirects will need to be in place. 301 redirects ensure that a user’s connection to your website is secured.

How Do I Create a 301 Redirect in WordPress?
There are two primary methods to create a 301 redirect in WordPress:
- Create a 301 redirect in WordPress manually. If you’re comfortable with the more technical realm of website files and server configurations, this method is for you. If not, you’ll need a plugin.
- Utilize a WordPress redirection plugin. This approach is probably preferable to those either managing a complex, commercial site, or multiple sites. Plugins can automate the process and perform it across all sites you own.
First, we’ll take a look at how you can manually make a 301 redirect for your WordPress site. In order to make a clear and concise tutorial, we’re going to make some presumptions about how you’re operating your site. These are outlined in the next section. Plugins can automate the process of 301 Redirect and perform it across all sites you own.
Second, we’ll take a look at how you might use plugins to perform this operation. The manual method may seem simple enough, but here are some reasons no WordPress site administrator should manually make their own 301 redirects for each of the respective sites they manage.
- Best practices make it clear that all changes across sites should be uniform. There will invariably be some minor differences if the redirect is manually made for each site you manage.
- As you’ll see, 301 redirects can turn from simple to complex pretty fast. When copying and pasting code, you still might run into text encoding issues (depending on the Operating System used), as well as other issues.
- Over time, you’ll need to make new updates. Memorizing this syntax would be nearly impossible. A plugin keeps everything consistent over the years and through your growth!
WordPress 301 Redirect Plugins
A WordPress plugin offers a simpler solution for your 301 redirect needs. These plugins will automate the process (you don’t have to know how or why it’s automated, but if you want to know the plugins use pure PHP, our WordPress function, or a hidden server file we’ll discuss below.
Redirection Plugin
The Redirection plugin allows you to manage your 301 redirections and keep track of 404 errors. It’s a handy plugin, one we actually use and recommend.
Easy Redirect Manager Plugin
The Easy Redirect Manager can also accomplish 301 redirects for you. Upon installation, you’ll just need to open it. You should see a table of links and be able to add any redirect with any status code applicable. Simply pick an old URL, enter the new URL with it, and ensure it’s marked as a 301 redirect.
Simple 301 Redirects Plugin
Simple 301 Redirects is an even more focused plugin. Solely intended for those looking to perform 301 redirects, it does more than just preserve the redirect. It’ll also ensure that those concerned about SEO rank won’t lose what they already have by making a 301 redirect for their WordPress site.
SEO Plugins Like Yoast SEO
Many WordPress SEO Plugins, like Yoast SEO, include 301 redirection as a premium feature within the plugin since 301 redirects are so vital to your site’s SEO. Check to see if your WordPress SEO plugin has 301 redirections as a built-in feature in either their free or paid version.
Getting (Super) Technical: WordPress 301 Redirect Without a Plugin
Next we’ll be going over how you can make a 301 redirect without a plugin. In this example, we’ll be covering how to make one URL redirect to another page on your site. The lower sections of this article will show how we can ensure that everyone accessing your site has a secured connection to and from your site. This is also known as “forcing WordPress SSL”.
We’ll be using the built-in WordPress PHP function called wp_redirect.
A 302 redirect means “temporarily moved” and does not update your search engine listings. This would ultimately be detrimental to any SEO strategy you have in place now or will try in the future. Not having your redirects update search engine listings be detrimental to any SEO strategy you have in place now or will try in the future.
In our example, let’s say you have a site called our-example-wp-site.com. Let’s assume a page on a URL – our-example-wp-site.com/old-url – needs to redirect to our-example-wp-site.com/new-url. Because we have WordPress installed, we don’t have to use raw PHP and can instead use that wp_redirect function.
Using wp_redirect
Using a file manager, navigate to the file containing the contents of our “old-url” page. Open this file to edit, and replace all the contents (other than the beginning and ending markers used by PHP) with this single line of code:
wp_redirect( "http://www.our-example-wp-site.com/new-url" , 301 );
As you can see, it’s a simple function with two parameters. The first parameter is the link to our old URL’s page. The second parameter is technically optional, but if left blank, will default to an HTTP status 302, which isn’t what we want.
Using Plain PHP
Depending on the version of WordPress you’re using, or for a variety of reasons, you may not want to use wp_redirect. By far, wp_redirect is the simplest WordPress-specific way to manage a single page redirect.
However, there’s also a way to perform the 301 redirect we want to do in pure PHP.
Since WordPress is based on PHP, we’re assuming your server must have PHP installed. In order to start, we’ll need to open up the file to edit in a file manager. This should be the file that contains the contents of the old URL that we need to redirect to a new URL.
Once again, let’s assume that we have the domain our-example-wp-site.com and that we want to redirect from our-example-wp-site.com/old-url to our-example-wp-site.com/new-url. Here’s the code that should go on our “old-url” page in plain PHP:
<? header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: http://www.our-example-wp-site.com/new-url" ); ?>
The first line of this code is the exact HTTP status response to send. Note that the prefix of HTTP/1.1 must be exactly as written. The next item must be the number of the status code. The portion that says “Moved Permanently” must be the correct corresponding string of words to our HTTP status code.
It gets tricky here. Technically, each item is a parameter in the string that the client’s browser reads. They all are manually typed in, but they must be exactly correct. Otherwise, the client will get a “bad header” error.
The second line in our PHP code must be the location of the new URL. This must contain the full path of the URL; in other words, we must include the entire URL, even if it’s a file within our own site. The reason is because it’s sent as the next browser header to the client, and it will be interpreted as written. Since the client won’t have all of your site’s files locally, it needs a reference to the complete, updated URL.
301 Redirect WordPress .htaccess
Regardless of whether you’re using WordPress as your content management system or not (or even if you have PHP installed), you can use .htaccess to make a 301 redirect happen. If you’re using a graphical file manager, you’ll need to view hidden files and folders.
The .htaccess file will be on your server in the “webroot”. That is, it’ll be in the top directory that holds your site’s contents. When adding anything to your .htaccess file, you should always back the file up first. These can get very long and complex. Another rule of thumb with these files is always to append edits, which means always adding edits to the bottom of the file.
First, locate your .htaccess file and back it up to your local machine. Once you’ve done that, you can open the live version on your server in a text editor. Go to the bottom of the file. In this example, we’re going to make sure that your site works regardless of whether a user enters “www.” before your URL or not.
The .htaccess 301 Redirect Code
Remember that the .htaccess file is spacing-sensitive. Put one space between each item you type in. We recommend typing rather than copying and pasting since these files are notorious for encoding errors due to copying and pasting. First, we’ll show you the code. Second, we’ll explain what it means:
RewriteEngine on RewriteBase / rewritecond %{http_host} ^our-example-wp-site.com [nc] rewriterule ^(.*)$ http://www.our-example-wp-site.com/$1 [r=301,nc]
In our first line, we’re turning on the Apache RewriteEngine. This essentially is booting up the component that allows us to rewrite the content and URL the client is going to see. The second line has us setting up from where we’ll rewrite. By putting “/” as the base, we’re telling our server that we want everything beginning at our webroot to be rewritten.
Analyzing Our .htaccess 301 Redirect Code
“rewritecond” in our third line sets up a “trigger” for when to rewrite our URL. The %{http_host} portion means it’ll get triggered on any attempted HTTP/S connection to our site. The carrot character before our domain means the trigger is set regardless of whether a user already put in “www” or whether they’re using a subdomain, etc. At the end, you’ll notice we put [nc]. This is Apache shorthand for “no case”, meaning that it shouldn’t pay attention to whether any part of the URL is upper or lower case.
The last line is what .htaccess should do when we hit that “trigger” in the third line. If it looks like a foreign language, that’s because it uses “regular expressions.”
In Computer Science, also called “regex” in short, it’s often used to format and rewrite all kinds of data. There are often entire semester courses in regex itself, so don’t feel like you need to learn it! Essentially, this line is using regex to preserve all of the URL, adding our “www.” before it, and that $1 within the URL is saying to keep everything after the “.com” in our domain.
At the very end of that last line, you’ll see we have [r=301,nc]. The first parameter in brackets, r=301 uses Apache shorthand again. ‘r’ is short for “Redirect HTTP response code to” and we’re indicating it should be 301. Our second parameter, ‘nc’, is used again to indicate that we’re not concerned about whether characters are upper or lower case.
Testing Our .htaccess Changes
Once you save and run this, try first deleting your temporary files and cache by going to your browser and pressing Ctrl+Shift+Del. Select everything, then press either “Apply” or “OK”, depending on which browser you’re using.
Try going to your domain without “www.” before it. It should now insert it if it wasn’t already there. Keep in mind that we’re actually inserting http://www.. If you have a valid SSL certificate installed, you’ll need to force SSL, as well. This is as simple as adding a single ‘s’, and changing what is inserted before our URL to https://www.
Wrapping Up: 301 Redirects and You
Nothing frustrates readers or search bots more than roadblocks. Frustrated readers don’t hang around and often don’t return.
It’s important to keep your readers moving to active pages if you want to keep your readers reading on your website. Implementing a plan for the use of 301 Redirects in WordPress benefits the readers, the search engines, and you.

Each week, the team at iThemes team publishes new WordPress tutorials and resources, including the Weekly WordPress Vulnerability Report. Since 2008, iThemes has been dedicated to helping you build, maintain, and secure WordPress sites for yourself or for clients. Our mission? Make People’s Lives Awesome.