Beginner’s Guide: How to Add 301 Redirects to WordPress

using wildcards in simple 301 redirects301 redirects deal with permanent moves.
You can redirect multiple pages to one new page, or automatically redirect all pages that meet certain criteria to their respective new version.
301 redirects are an SEO best practice whenever you change the URL of any piece(s) of content on your WordPress site.

What Does a 301 Redirect Do?

For example, let’s say you have an entire category of posts like:
So, to help you out, I’m going to use this post to dig into 301 redirects as they apply to your WordPress site.
To redirect a single page to another single page, you can use:
While it’s possible to add basic 301 redirects to your .htaccess file, as well, if you’re just redirecting content within your existing WordPress site, I think it’s easier to use Simple 301 Redirects.
If you need to set up broader redirects – like to redirect an entire domain to another domain or redirect traffic to SSL, you can also implement 301 redirects via your .htaccess file.
#Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/ [R=301,L]

You Can Redirect More Than a Single Page

Wildcards are a slightly more advanced feature that let you dynamically redirect multiple pages to one or more associated pages.
Here are some examples of the types of 301 redirects that you can implement:
yourdomain.com/old-page

Some Examples of When WordPress Users Need 301 Redirects

Let me go back to the example to show you how it works.

  • Changing your permalink or slug structure. If you do so, you’d want to redirect URLs using your old permalink or slug structure to your new one.
  • Changing the URL of a single post or page. WordPress should automatically redirect the old post’s URL to the new one, but I still recommend manually setting up a 301 redirect because the process doesn’t always work.
  • Consolidating multiple posts into one. Some SEO experts recommend consolidating multiple small posts into one monster post. If you do that, you’ll want to 301 redirect all those small posts to the big one.
  • Moving to HTTPS/SSL on your site. If you add SSL to your WordPress site, you need to make sure to add a 301 redirect to send all unsecured traffic to the SSL version of your site.
  • Changing your domain name. If you completely change your domain name, it’s essential that you use 301 redirects to redirect traffic from your old domain to your new domain name.

yourdomain.com/travel/POST-SLUG

How to Add 301 Redirects to WordPress With Simple 301 Redirects

Rather than going through the tedious process of manually redirecting every single post, you can use wildcards to automatically handle the process for you.

  • You can quickly create 301 redirects without leaving your WordPress dashboard
  • It makes it much easier to manage your existing 301 redirects
  • It’s just plain easier for beginners than digging around the .htaccess file

Then, click Save Changes.
how to add 301 redirects to wordpress

Redirecting a Single Page to Another Page

Basically, if you want to redirect human traffic and have your new page to maintain the same Google rankings as the old page, a 301 redirect is usually your best bet.
While you can use the full URL, using only the portion relative to the root is a cleaner way to do it.
Now, I want to get a little bit more specific and actually give you some examples of when you’d want to use a 301 redirect on your WordPress site.
For our example, that means you would configure the plugin like this:
Below, I’ll show you two methods to add 301 redirects to WordPress to handle these various situations.
And that’s all there is to it! Anyone who visits the old URL will be automatically redirected to the new URL.
Let’s start with the easiest example – redirecting a single post or page to another single post or page.

  • Request: /old-page
  • Destination: /new-page

Otherwise, you can use .htaccess to manually 301 redirect all or part of your WordPress site.
Where each portion is the part of the URL that comes after your domain name (just like with the Simple 301 Redirects plugin).
examples of wildcards
where to find .htaccess file

Using Wildcards For More Complex 301 Redirects

If you recently set up SSL, you should add 301 redirects to send http traffic to https for better security and to avoid duplicate content.
If you’re already familiar with the basics, you can click the button below to jump straight to the tutorials:
Go Straight to Tutorials
Otherwise, let’s get started!
You can even get more creative with wildcard redirects if you want. Here are some examples from the plugin’s documentation:
The main benefit of this permanent approach deals with SEO. According to Moz, a 301 redirect “passes between 90-99% of link juice (ranking power) to the redirected page.”
Have any further questions about how to add 301 redirects to WordPress? Let us know in the comments and we’ll try to help out!
To do that, add the following code snippet:
All you need to do is grab the URL of each page relative to your site’s root domain. Most of the time, that means you just want to take the portion of the URL that comes after “.com” (or whatever your domain name ends with).
For most minor 301 redirects, you can use a free plugin called Simple 301 Redirects. While you can manually use .htaccess for everything (the next method that I’ll show you), I like this plugin because:
To add 301 redirects to your WordPress site, you’ll need to connect to the root folder of your WordPress site via either FTP or cPanel’s File Manager tool.
If you configure Simple 301 Redirects like this:

  • Request: /travel/*
  • Destination: /adventure/*
  • Check the Use Wildcards? box

Now, let’s say you want to change the category slug to “adventure”. So you want all of those 10 posts to have the new URL of:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  • yourdomain.com/travel/vietnam gets redirected to yourdomain.com/adventure/vietnam
  • yourdomain.com/travel/thailand gets redirected to yourdomain.com/adventure/thailand
  • Etc.

Let’s say you want to redirect:
yourdomain.com/adventure/POST-SLUG

How to Add 301 Redirects to WordPress via .htaccess

simple 301 redirects
You have 10 posts in the travel category, all using that same URL category slug.
Then, look for the .htaccess file:
One neat thing about 301 redirects is that you aren’t forced to use 301 redirects on a 1:1 one basis.
That is, a 301 redirect tells web browsers and search engines, “hey, this page has permanently moved to a new location. So treat it exactly the same as the old page”
yourdomain.com/new-page
You need to add this snippet to the .htaccess access file of your old domain name – not your new domain name.
In general, redirects are a way for you to automatically send visitors who land on Page A straight to Page B. Essentially, you use a redirect to automatically reroute traffic if you ever need to move a page (or pages).

301 Redirect a Single Page via .htaccess

I’ll cover these more advanced types of 301 redirects in more detail below.
Before you make any changes to your site, it’s important to back up your existing .htaccess file. Even small mistakes can tank your site – so you definitely want a recent backup handy in case anything goes wrong.
Make sure to replace “newdomain.com” with your actual new domain name.

Set Up 301 Redirects for Moving to SSL

To get started, install and activate the plugin. Once it’s activated, you can head to Settings → 301 Redirects to start setting up some 301 redirects:
To manage 301 redirects directly from your WordPress dashboard, Simple 301 Redirects is a great free plugin.
Redirect 301 /old-url /new-url

301 Redirect an Entire Domain via .htaccess

There are different types of redirects you can implement on your site, usually marked by a certain number. Without getting too technical, these numbers essentially refer to whether or not the page has moved permanently or temporarily.
That configuration means that:
Once you’ve backed up the current contents of your .htaccess file, you can add 301 redirects to the top of the .htaccess file.
If you’re moving your WordPress site to a new domain name, the following code snippet will redirect every single page on your old domain to the exact same page on your new domain (assuming you keep the same permalink structure):

Wrapping Things Up

Basically, a wildcard, represented by an asterisk *, is “any dynamic value entered in that part of the URL structure”.
I’ll start with a basic discussion of what 301 redirects are and when you’d want to add 301 redirects to WordPress. Then, I’ll show you how to get them set up using either a free plugin or your .htaccess file.
To
Struggling with how to add 301 redirects to WordPress? These nifty redirects are an SEO friendly approach that let you re-route traffic to your site in a number of helpful ways. But they’re also confusing for many casual WordPress users.

Posted by WordPress Guru