How to Create 301 Redirects in WordPress (4 Methods)

by Jason Cosper
How to Create 301 Redirects in WordPress (4 Methods) thumbnail

Sometimes, you’ll have to move or delete certain pages on your website. It’s the circle of [website] life.

But if you do move or delete a page, users could potentially be presented with a 404 error that prevents them from accessing your content, often leading to an exit. If you don’t properly set up redirects, you may increase your bounce/exit rates, which harms user experience (and potentially organic rankings).

Fortunately, it is easy to create 301 redirects in WordPress — by adding a 301 redirect for moved or removed pages, users (and search engines) will be whisked off to the new, updated URL. Whether you use a redirection plugin or edit your site files, building 301 redirects can effectively fix any broken links on your site.

In this post, we’ll explain what 301 redirects are and when you might want to use them. Then, we’ll show you four ways to create a 301 redirect in WordPress. Let’s get started!

An Introduction to Redirects

To get started, you’ll need to know what redirects are. Put simply, any redirect will send users and search engines to another web address. This automatically redirects the requested URL to a different location.

As a website owner, you can use a temporary or permanent redirect to prevent your visitors from seeing error pages. These “Not Found” errors, otherwise known as 404 errors, inturrupt the browsing experience and can lead to visitors exiting your website.

DreamHost Glossary

What are 404 Errors?

A 404 error is an HTTP status code that indicates that the page a user is trying to access does not exist. 404 errors can occur for a wide variety of reasons, but they almost always lead to a poor User Experience (UX).

Read More

There are many other different redirect types as well. Each one sends a unique HTTP status code from a web server to a browser. These codes indicate how the content is being moved.

Here are the most common URL redirect types:

  • 301: Permanent redirect from one URL to another.
  • 302: Temporarily redirect to a new URL.
  • 303: Non-cacheable redirect to temporarily replace content.
  • 307: Informs search engines that the redirect may periodically update.
  • 308: Permanent redirect that disallows changes from POST to GET request methods.
  • Meta refresh: Client-side redirect that often appears as a refresh countdown timer.

By far, the most used redirect type is a 301 redirect. This will inform both search engines and online users that the original resource is no longer available. Instead, it will permanently redirect to a new page.

Whenever someone clicks on the original link, they’ll automatically be taken to a different URL. The redirect will seamlessly direct users to the correct pages on your website and prevent them from seeing 404 errors.

Reasons You Might Use a 301 Redirect

Since there are different redirect types, it can be difficult to know which is right for your website. Fortunately, 301 redirects are useful when performing a few essential management tasks.

One of the most common reasons to use a 301 redirect is when you’re deleting old content. If a post is no longer relevant but still receives traffic, you’ll want to take these users to an updated resource.

In this case, 301 redirects tell search engines that you’re permanently moving the URL. Since it will preserve your traffic and backlinks, this redirect can improve your Search Engine Optimization (SEO). However, keep in mind that it can take time for search bots to discover the new page and associate it with the same ranking.

Additionally, you may implement 301 redirects if you’re moving to a new domain. If you don’t redirect your URLs, you may quickly lose your current audience. However, 301 redirects will seamlessly take visitors to your new location.

Similarly, a 301 redirect can be useful when moving from an HTTP to an HTTPS connection. To make sure users visit the secure version of your website, it’s best to permanently redirect your content.

You might also want to consolidate separate posts. After compiling the information onto one page, you can redirect all the old links to the new location.

Get Content Delivered Straight to Your Inbox

Subscribe now to receive all the latest updates, delivered directly to your inbox.

How to Create 301 Redirects in WordPress (4 Methods)

Now that you know about 301 redirects, you may want to apply them to your website. Let’s discuss some best practices when creating 301 redirects in WordPress!

Method 1: Install a Redirection Plugin

One of the best ways to extend the native functionality of WordPress is to install a plugin. Fortunately, there are many useful plugins available for creating and managing your website’s redirects.

For example, Redirection is a free tool that adds a redirect manager to your site. You can use this plugin to set up 301 redirects, track broken links, migrate permalinks, and much more:

Redirection WordPress plugin

To get started, install and activate Redirection in WordPress. Then, navigate to Tools > Redirection. On this welcome page, click on Start Setup:

Redirection plugin setup

For the next step, you’ll need to decide whether you want Redirection to monitor permalinks, redirects, and 404 errors on your site. If so, enable these options and select Continue:

Redirection plugin monitoring

After this, the plugin will test your REST API to see if it can communicate with WordPress properly. Once you receive a ‘Good’ rating, you can click on Finish Setup:

Redirection test REST API

Now you’ll be able to create a 301 redirect! To do this, find Tools > Redirection > Add New. Then, add your source URL and target URL:

Add new redirection

Lastly, click on the gear icon to open additional settings. Be sure to select a 301 – Moved Permanently HTTP code:

Create 301 permanent redirect

When you’re finished, hit Add Redirect. Now, whenever users visit the old URL, their browser will automatically reroute to the new resource!

Method 2: Use Your SEO Plugin

Although you can install new redirection plugins like Redirection or Simple 301 Redirects, you may already have all the tools you need to create redirects on your website. Often, SEO plugins provide redirection managers along with Search Engine Optimization features.

Rank Math is a free SEO plugin with built-in redirection tools. With this tool, you’ll be able to enable, disable, and delete any of your site’s redirects. Plus, it even imports information from the Redirection plugin:

Rank Math SEO plugin

After you install and activate Rank Math, open the dashboard. Then, find the Redirections tool and enable it:

Enable Rank Math redirections

Now you’ll have a new Redirections tab. On this page, click on Add New:

Rank Math redirections

First, you can add your original source URL, which will be the content you’re redirecting from. By hitting Add another, you can paste URLs in bulk. This can be an efficient way to consolidate multiple pieces of content into one source:

Bulk 301 redirects

Next to each URL, choose Exact Match if you want to redirect this exact link. However, you can also enter a more general term. By selecting Contains instead, every page with that keyword will be redirected:

Source URL keyword

Under Destination URL, insert the link you want users to visit. Be sure to also select 301 Permanent Move as the redirection type before hitting Add Redirection.

Method 3: Edit Your .htaccess File

If you want to avoid installing another plugin, you can also create 301 redirects manually. Since this involves editing your site files, be sure to back up your website first. This will save a copy of your current website to revert back to if anything goes wrong.

Next, you’ll need to connect to a File Transfer Protocol (FTP) client or your host’s file manager. For DreamHost users, sign into your account panel. Then, navigate to Websites > Manage Websites > Manage Files SFTP > Manage:

Open DreamHost SFTP file manager

This will open DreamHost’s file manager. Here, you’ll need to find the .htaccess file within the root directory:

Edit .htaccess file

If you don’t want to back up your entire website, you can simply download this original file. If you experience any problems, you can re-upload it to the server:

Download .htaccess file

Once you locate the .htaccess file, right-click on it and select Edit. If you’re using the DreamHost file manager, a text editor will automatically open:

.htaccess file editor

Right below the ‘# END WordPress’ line, add this new coding to create a 301 redirect:

RewriteEngine On
Redirect 301 /new-content/ https://mywebsite.com/new-content/

Be sure to update both of these URLs so that they’re unique to your website. Keep in mind that if you already have Rewrite Engine on in your .htaccess file’s coding, you don’t need to repeat it. You can simply copy and paste the redirect code.

As we mentioned earlier, you may want to redirect your entire website to a new domain. In this case, you can use the following coding instead:

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

If you’re migrating your website from an HTTP to HTTPS connection, you can also do this in your .htaccess file. Simply paste this code:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

After this, save the file and close it.

Method 4: Create a Server-Side Redirect

As another alternative, you can also create 301 redirects in PHP. This will be a server-side redirect that uses header() functions.

PHP redirects are server-facing, so they can often be faster and more secure. However, this is a fairly technical process that can easily go wrong. Make sure you’re knowledgeable in PHP coding before getting started.

To properly redirect in PHP, you’ll need to write a header() function. In the location response-header field, define the URL where you want to send search engines and users:

header('HTTP/1.1 301 Moved Permanently');
header('Location: https://www.example.com/newurl');
exit();

Be sure to include a die() or exit() function at the end of the header. Without it, search engines like Google may process the original page and ignore your new redirect.

How to Troubleshoot 301 Redirects

After you create a 301 redirect, it may not perform correctly. Sometimes, it’ll turn into a redirect chain or loop. This happens when there are multiple redirects between the original URL and the target URL.

If your website has a redirect chain, visitors can see a ‘Too many redirects’ error. Essentially, the browser won’t be able to fulfill the redirect and display the correct page.

As the site owner, you may not notice redirect chains. To check for any errors, you can enter URLs into a redirect checker like HTTP Status:

HTTP Status redirect checker4

You’ll be able to paste up to 100 URLs into the text box. Then, hit Check status. At the bottom of the page, you’ll see the HTTP status code and the number of redirects:

Redirect checker results

If the page loads correctly, you’ll see a ‘200’ HTTP status code. You should also make sure there is only one redirect for every URL. Otherwise, you’ll likely have a redirect chain.

Common Redirect Mistakes

A common mistake when building website redirects is confusing 301 and 302 redirect types. Although both will redirect to a new page, they communicate with search engines in different ways. Since this can negatively impact your SEO, it’s important to know the difference.

As we mentioned earlier, 301 redirects are permanent. This will inform search crawlers to stop indexing the original content because it was permanently moved. In this case, the new content will receive the link equity of the old page.

On the other hand, 302 redirects indicate that the redirect is temporary. If you’re testing out a new redesign, you may temporarily redirect visitors to another location during development. A 302 redirect tells search engines that the original content will return, so it needs to keep its PageRank and indexing.

Additionally, you’ll want to regularly keep track of any redirects you create. If you don’t, your site could end up with infinite redirect loops that increase your bounce rate. Ultimately, you’ll want both search crawlers and online users to easily and quickly access the right content.

Lastly, make sure you redirect to updated content that is relevant to the original page. Since visitors clicked on the original link, you’ll need to provide helpful information.

This will ensure the transition is smooth, preventing users from quickly leaving and going to your competitor. Plus, it will make sure crawlers continue to understand your content so you rank higher in search results.

If you’re trying to consolidate your online content or move to a new domain, you’ll need to set up 301 redirects. This can help you maintain steady traffic and avoid losing your high Google search ranking. Plus, redirects can prevent visitors from clicking on broken links.

To review, here’s how to create 301 redirects in WordPress:

  1. Install the Redirection plugin.
  2. Use an SEO plugin like Rank Math.
  3. Edit your .htaccess file.
  4. Create a server-side redirect with PHP.

Are you worried that your redirects will negatively affect your SEO? Here at DreamHost, we provide professional SEO marketing services to help your website rank high in search results!

Ad background image

Search Engine Optimization Made Easy

We take the guesswork (and actual work) out of growing your website traffic with SEO.

Learn More

Jason is DreamHost’s WordPress Product Advocate, based out of Bakersfield, CA. He is currently working on making our DreamPress product even better. In his free time, he likes to curl up on the couch and watch scary movies with his wife Sarah and three very small dogs. Follow him on Twitter.