How to Add 301 Redirects to WordPress 2021

When a search engine crawls your website and has trouble finding pages that are supposed to be there, it makes note of these negative results, and your search engine Indexing is affected. If you have ever changed a URL on your website, or your permalink structure you must add redirects in WordPress to maintain the SEO. Here this post we discuss the importance of redirect in WordPress, And how to add 301 redirects to WordPress.

What are redirects in WordPress?

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).

There are different types of redirects you can implement on your site, usually marked by a certain number. Here’s what each one refers to, According to Search Engine People:

  • 301 redirect: 301 redirects stand for permanent redirects that inform search engines that the location of the page they intend to send visitors has been altered. It passes almost 90 percent of ranking power (link juice) to the redirected web page.
  • 302 redirect: 302 redirects are temporary redirects that inform search engines that a location of the page they intend to send visitors to is changed for the moment, but not forever.
  • 303 redirect: A few web pages store one-time-only information (like landing pages that act as payment forms). You may want to prevent these pages from being refreshed or saved. By setting up 303 redirects, you can instruct the server to tell visitors that if they submitted the form, they should visit this URL and change the method how they did that. It’s a temporary redirect that ensures the page storing data can’t be refreshed or bookmarked.
  • 307 redirect: Very similar to the above.
  • 308 redirect: A 307 with a permanent status.

301 redirects deal with permanent moves.

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” 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.” 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.

When do you need to setup 301 Redirects in WordPress?

Here some examples of when you’d want to use a 301 redirect on your WordPress site.

  • You change the directory of your WordPress installation.
  • You have moved your website to a New domain, and you want the old URLs from a previous website to point to new URL.
  • You change the Permalinks (URL structure) of your posts and want to redirect people visiting old pages to right pages.
  • You want to maintain a preferred (canonical) destination for your homepage. (Redirecting www version to non-www version of your homepage).

How to Add 301 Redirects to WordPress

Redirection is one of the most popular plugins available in the official WordPress repository, help to setup 301 redirections with few clicks.

  • Download and Install the Redirection plugin from the WordPress repository or by searching it within your dashboard.
  • After activating the plugin, go to Tools > Redirection
  • Define the Source URL (your old, existing URL) and the Target URL (your new URL that you want to redirect to) and click on Add Redirection.
  • A 301 redirection type is added by default! And that’s all that you need to do

Add 301 Redirects to WordPress via .htaccess

If you are using Yoast SEO plugin then you can easily edit your .htaccess file (more on that later) which you can use to add 301 redirects.

  • From your WordPress dashboard, go to SEO > Tools and you should see a list of built-in tools for WordPress
  • Click on the File editor tool that lets you edit your .htaccess file.
  • Important: Backup your .htaccess file before you make any edits. (In case you mess up your .htaccess file here, you won’t be able to access your WordPress dashboard. You will need to login into your FTP client and correct the syntax or restore the .htaccess file that you have backed up.
  • You will see two boxes for Robots.txt file and .htaccess file on this page.
  • Add your redirection code in the .htaccess file box and click on save changes to .htaccess. Here is an example:

Set Up 301 Redirects for Moving to SSL

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.

To do that, add the following code snippet:

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

301 Redirect an Entire Domain via .htaccess

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):

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

You need to add this snippet to the .htaccess access file of your old domain name – not your new domain name.

Make sure to replace “newdomain.com” with your actual new domain name.

Hope now you can easily add and setup 301 redirects in WordPress. Have any query, feel free to discuss on comments below, Also read:

Redirects