How To Set Up 301 Redirects In WordPress?

How To Set Up 301 Redirects In WordPress

In lots of conditions, we need to change the URL of our already published post/pages. Even sometimes, we need to change the domain name because of a certain reason.

Recently we have faced a “Japanese Keyword Hack.” on one of our websites, and we have to change the domain just because hundreds of spam URLs are indexed in google.

Thanks to 301 redirects, we change the domain of our website without any traffic loss. 

But changing the domain or URL by creating 301 redirects is not an easy task. This article is for you if you are going to create a 301 redirection on your website.

Below we have shared everything you need to know, how you can set up 301 redirects with a free plugin and without using a plugin?

What Is A 301 Redirect?

301 is the type of redirection used to move the post/page to a new URL permanently.

In simple words, when you move any of your already published posts/pages to a new domain or URL, you have to create a 301 redirect to redirect the existing traffic on the particular page to a new one. 

You can redirect the user to a new URL with various other redirections like 302 redirects, but when you use 301 redirects, search engine crawlers mark it as the permanent redirection.

With a 301, search engine crawlers pass more than 90% of link juice to the new link.

When Do You Need To Use 301 Redirects In WordPress? How is it useful for SEO?

Before creating 301 redirects, it is very important for you to know when you should create 301 redirects and when you can use other types of redirection. 

  • You change the URL of your already published post/pages.
  • You change the location of your WordPress installation.
  • You change the website domain name and permanently move your website to another domain. 
  • You change the permalinks of your posts and want to redirect users to the new URL. 
  • You want to maintain a preferred (canonical) destination for your homepage.

If you have done any of the above, you should add 301 redirects to tell the search engine that you have permanently moved those pages.

Here is the main question: how is the 301 redirect helpful in terms of SEO?

When you add the redirection from one URL to another URL, then you redirect the visitors along with the link authority of your previous page to the new one. That’s where the 301 redirect helps us. 

Create A 301 Redirection In WordPress With Plugin

1. Redirection by John Godfrey (free)

Redirection by John Godley is the dedicated free to use redirection plugin to create and manage 301 redirects.

You can also add the redirection base on the specific condition, like “Login status,” “WordPress capability,” “HTTP headers.”

This plugin is not just limited to the redirection. It will also help you monitor the 404 errors that occur on your site. 

One of the best features in this free redirection plugin is automatically adding a 301 redirection when you change your existing post’s URL or the permalink structure.

No need to worry about anything. If you are currently using any other redirection plugin, then you can easily import your already created redirections from there. 

And if, after creating hundreds of redirections, you don’t want this plugin, then also you can easily export the data. Here is how you can set up 301 redirects with Redirection.

Step 1: First, log in to your WordPress website.

Step 2: Click on Plugin >> Add new >> Search for “Redirection by John Godley”

Step 3: Once you have done with the installation, go to Tools >> then click on the Redirection option at the end.

Redirection By John Godley
Redirection By John Godley

Step 4: From here, you can create and manage all your redirections. 

Source URL: The URL you want to redirect (old URL)

Target URL: To where you want to redirect your visitor (new URL)

With the same process, you can add unlimited redirections.

2. 301 Redirects – Easy Redirect Manager

301 Redirects – Easy Redirect Manager is another best redirection plugin that allows you to create all redirection types, including 301, 302, 307. 

It features a straightforward interface. What you have to do is to install the plugin, and you are ready to create redirection. 

Another good thing about it is that this plugin is fully compatible with almost all the translation plugins like Weglot, TranslatePress, Gtranslate, and Loco Translate, which mostly uses the extended prefix of URL.

This free plugin will also let you know how much redirection is used. Here is how you can install and configure it. 

Step 1: First, log in to your WordPress website.

Step 2: Click on Plugin >> Add new >> Search for “301 Redirects – Easy Redirect Manager”

Step 3: Once you have done with the installation, go to Settings >> then click on the 301 Redirection option at the end.

301 Redirects Easy Redirect Manager
301 Redirects Easy Redirect Manager

Step 4: From here, you can create and manage all your redirections. 

Enter your old URL and new URL, then click on Save

3. Yoast SEO (premium version)

You can also easily set up the 301 redirects if you are already using the Yoast SEO on your WordPress website. But for that, you should have the premium version of Yoast SEO.

When you delete or move any content to another URL, the Yoast plugin will notify you to create the redirections. Here is how you can setup 301 redirects.

Step 1: Go to Yoast SEO

Step 2: Click on Redirection, for here you can easily set up a 301 redirection. 

Yoast SEO 301 Redirections
Yoast SEO 301 Redirections

Creating A 301 Redirect In WordPress Without A Plugin

Creating a 301 redirection without a plugin is quite tricky. You have to edit the core WordPress file for that. You can do it in two different ways,

  • Create A 301 Redirect With .htaccess
  • 301 Redirect With Functions.php

In order to create 301 redirects by editing .htaccess, you need to have the server access. If you are using the managed WordPress website hosting, then it is not possible for you. 

Talking about the second way of creating redirects with functions.php, you don’t need to have the hosting access, you can quickly edit the functions.php file for the WordPress dashboard

1. How To Create A 301 Redirect With .htaccess?

The .htaccess is just an understandable text file that allows you to make changes affecting how your server delivers your pages. 

You will get the .htaccess file in the folder where you have installed the WordPress for your domain name. If WordPress is installed in a subdirectory, it will be located there. 

Before making any change in the .htaccess file, you should download the backup so that you can quickly fix it by uploading the default .htaccess file in terms of any problem.

Here is how you can do it. 

Step 1: First of all, login to your host (cPanel)

How To Create A 301 Redirect With .htaccess.
How To Create A 301 Redirect With .htaccess.

Step 2: Then go to File Manager, locate your WordPress installation. If your domain is your primary domain or there is only a single website hosted, you will find it in the public_html folder

Setup 3: Once you locate the .htaccess file, download the backup copy.

Step 4: Now, right-click on the file and then click on edit. 

How To Create A 301 Redirect With .htaccess 1
How To Create A 301 Redirect With .htaccess

From here, you can easily add 301 redirects by using the below code. 

  • Redirect to a page on the same host: Redirect 301 /oldpage.html /newpage.html
  • Redirect to a page on a different host: Redirect 301 /oldpage.html https://www.example.com/newpage.html
  • Redirect entire WordPress site to a new site: Redirect 301 / https://www.yournewsite.com/

Just replace the dummy URL with your one and save the file. Make sure you should not edit any other code in the file. 

2. How To Create A 301 Redirect With Functions.php?

It is straightforward to create a 301 redirection by editing functions.php, but you should create a backup of your entire website because a single mistake may lead to error. 

To edit the functions.php, follow the below steps. 

Step 1: Log in to your WordPress website as Admin

Step 2: Go to Appearance >> Click on Editor.

Step 3: From here, select Theme Functions (Functions.php)

Step 4: Scroll to the bottom of the file and insert the below code by changing the dummy URL with your original one. 

if($_SERVER['REQUEST_URI']=="/wp-design/some_page_you_want_to_redirect")

{
wp_redirect( ‘http://mysite.com/mynewpost’, 301 );
exit;
}

RankMath 404 Monitor And Redirection Plugin

This final mention goes to the Rankmath 404 and Redirection plugin. RankMath is a free to use, leading WordPress SEO plugin that comes with hundreds of unique features. 

It allows you to customize all the necessary SEO settings easily. You can control which page you want to index and which not. Not just about the basic SEO setup, you can add Schema to your post or pages.

If you are already using RankMath, then there is no need to install any other redirection plugin because RankMath allows you to monitor 404 errors and add 301 redirects. 

Here is how you can do it, 

Step 1: Log in to your WordPress website.

Step 2: Go to RankMath option >> Click on Redirections. 

RankMath 404 Monitor And Redirection Plugin (2)
RankMath 404 Monitor And Redirection Plugin

Step 3: Now, you will get the Add New option at the top of the page, click on it. 

RankMath 404 Monitor And Redirection Plugin (1)
RankMath 404 Monitor And Redirection Plugin

From here, you can easily add 301 redirects and manage it.  

Other Types Of Redirects

301 redirect is not the only type of redirection. You can use it if you are going to change the URL of the post/pages permanently. For temporary change and others, you should go with a different type of redirections.

308 RedirectPermanent Redirect (experimental)
307 RedirectTemporary Redirect
303 RedirectSee Other
302 RedirectFound (was: temporary redirect)
301 RedirectPermanent Redirect
Other Types Of Redirects

Final Words

That’s how you can easily create 301 redirects on your website with or without using a plugin. Now the question arises, which is the best way to create a redirection?

If you are not a tech-savvy guy or developer, then we highly recommend you to go with plugins because editing core WordPress files is quite risky.

When it comes to the plugin, you don’t have to install a separate plugin if you are using RankMath or Yoast SEO Premium. Both the SEO plugins provide you with the option to create unlimited 301 redirects for free.

We hope this article helps you in solving your problem. Do share it on social media and stay connected with us for future updates.

Leave a Comment

Your email address will not be published.