Setting Up 301 Redirects in WordPress: Plugin and .htaccess Methods Explained

Setting Up 301 Redirects in WordPress: Plugin and .htaccess Methods Explained

Are you trying to create a 301 redirect WordPress?

Don’t know what the redirect is and why it’s important? 

Don’t worry, in this article, we will introduce what it’s like to 301 redirect in WordPress, how to do it, why you need it, and when you should use redirection. 

Are you ready? Let’s get started. 

What is the redirection in WordPress? 

Redirect is your site by sending a quick message to a reader’s browser and telling him that the page you want to visit has been moved, so your browser can automatically direct them to a new page of your choice. 

There are several different types of redirection, such as 301 redirections, 302 redirections, 307 redirections, etc. But to make the article simple and useful, we will only introduce 301 redirects because that’s what matters most. 

Let’s see why it matters in understanding the use case. 

When do you need 301 redirect WordPress? 

The main reason for using 301 redirects is that you want to point users to a new page when the site or site page is moved. 

The idea of this post came to us when one of our readers asked us to redirect users from old posts to new ones. 

  1. When you plan to delete a post or page to support new content, you must create a redirect. 
  2. When you plan to change a permanent link to a post or page, you need to create a redirect. 

Why?

Because you do not create a redirect, users will see a 404 Errors not found. This is not only bad for users but can also affect the ranking of your site’s search engines and compromise your search engine ranking. 

This is when the 301 redirect becomes very important. It allows you to tell Search Engines and Browser users that the page they are trying to access has been permanently moved to a new location. 

This allows the traffic advantage and backlink (SEO) of all your old pages to switch to the new page.

Now that we’ve covered the reasons and redirection times, let’s see how to create 301 redirects in WordPress using different methods. 

How to create a 301 redirect WordPress (using plugins)?

An easier way to create and manage a 301 redirect is to use one of the many WordPress redirection plugins.

This allows you to set redirects without writing a single line of code. 

#1 Redirection

Setting Up 301 Redirects in WordPress: Plugin and .htaccess Methods Explained image1

The easiest way to add and manage 301 redirect WordPress is to use the redirect plug-in. Install and activate the add-in. Once enabled, access the “tool redirection” to configure your redirection. 

The Redirection Plugin not only allows you to set redirection but can also help you figure out 404 errors on your WordPress website. You can then redirect those URLs to a suitable destination. 

#2 Page Links to

Setting Up 301 Redirects in WordPress: Plugin and .htaccess Methods Explained image2

Page Links To plugin adds a meta-box to the post editing screen where you can enter the address of the new location you want to send to the user. 

#3 Simple 301 Redirects

Setting Up 301 Redirects in WordPress: Plugin and .htaccess Methods Explained image3

As the name suggests, it makes 301 redirects simple. Just install and activate the plugin and then visit Settings” 301 redirects to add your URL. 

Now, while setting 301 redirects with the Simple 301 Redirects Plugin is easy, it has some minor performance setbacks.

Depending on your WordPress Hosting Provider, your WordPress redirection may be a few microseconds slower. 

If you want your redirection to be faster, you can do this by using code methods and .htaccess files. 

Set 301 Redirect WordPress using .htaccess

With .htaccess web server configuration file, WordPress users can configure 301 redirections quickly. 

Note that a small error in the .htaccess code may make your WordPress website inaccessible and may start showing internal server errors. 

That’s why it’s important to back up the .htaccess files before making any changes. Edit your .htaccess file, you need to connect to your website using FTP client. The htaccess file resides in the root directory of your WordPress website. 

If you can’t see your .htacces file there, then you need to force your FTP client to show hidden files. (See why you can’t find the. htaccess file on your WordPress site.) 

You can edit the .htaccess files in any plain Text Editor, such as Notepad. Here is a simple redirect where we try to send users accessing old posts to new ones. 

RewriteEngine On
Redirect 301 /a-very-old-post/ http://yoursite.com/a-very-new-post/

You have to add the above code to the end of the .htaccess file. 

Create 301 redirect WordPress with PHP

As a WordPress developer, you have two options: either redirect by changing the header of the file in the code – or – use the wp_redirect function.

An example of a normal PHP may look like this:

<?php
// MyExampleFile.php
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: http://www.my-blog.com/a-new-destination"); 
?>

Here’s how you do the same, but now using the built-in WordPress function:

wp_redirect( "http://www.my-blog.com/a-new-destination", 301 );

If you forget to add 301, both WordPress and PHP will assume that it is a 302 redirect, which is not always the case.

This method is a little easier than editing a file on a server, but once the redirect vector increases, it can also become cumbersome.

We hope this beginner’s guide to creating 301 redirect WordPress will help you set redirects on your website. 

In case of any further problems, you can Contact Us via mail, chat, or call. You can just drop in a comment below, we will contact you asap.

Related Articles

Guide to Minifying JavaScript, CSS, and HTML in WordPress

Guide to Minifying JavaScript, CSS, and HTML in WordPress

Do you want to minify JavaScript, CSS, and HTML Files in WordPress website?

Understanding HTTP Errors: The Six Most Common Codes

Understanding HTTP Errors: The Six Most Common Codes

Have you ever encounter an HTTP error and wonder, ‘what is an HTTP error’?

How to Edit Database Configuration Files in Magento

How to Edit Database Configuration Files in Magento

When you are working on Magento, you may have to make changes in Magento database configuration file, now and then.

Tell your friends about this Article!

© Copyright 2019 - 2024 YouDBox.site. All Rights Reserved.