301 Redirects in WordPress【Step By Step Guide】

301 Redirects in WordPress

0 Comment

7 mins Read

301 Redirects in WordPress

Broken links may happen for a number of reasons. This is an issue that has a negative impact both on SEO and on the experience of the users. A good tactic for avoiding broken links is creating redirects. In this article, we will explain 301 redirects in WordPress, as well as some useful WordPress plugins that help in redirecting.

301 Redirect with htaccess in WordPress

301 redirect in htaccess is an option that can be found in the htaccess file, placed on the WordPress server. But what does it really do? Which WordPress redirect plugins are good? What is the main function of a WordPress redirect plugin? Is there a plugin or a code to redirect HTTP to HTTPS? What is HTTP redirect 301? How about PHP redirect 301? In this article, we answer these questions and more. Let’s begin by explaining the redirect codes, and what the 301 redirect code is.

Start Blogging Start Blogging

Self-host your WordPress on top-tier hardware, featuring NVMe storage and minimal latency around the world — choose your favorite distro.

Get WordPress VPS

What is Redirect in WordPress?

Redirection is a way to forward both search engines and users to a different URL from the one they originally tried to reach. You may need to redirect a page for a number of reasons.

5 situations that Redirects in WordPress is needed

  1. finding a broken link
  2. moving your web page to a new address
  3. changing the domain name
  4. maybe they need for deleting a page.
  5.  Fixing the “HTTPS not secure” error

As you may know, in the absence of a redirect code, a 404 error (Page Not Found) will occur, and this error can hurt the ranking and reputation of your website. It can also have a negative effect on the user’s experience.

Using the redirect code, you let browsers know that the requested URL has been moved or replaced. Three of the most commonly used redirects are the 301 redirects, the 302 redirects, and Meta Refresh or JavaScript redirects. 301 redirects are permanent, therefore the 301 redirects are recommended for SEO. Next, we will explain it in more detail.

What is the 301 Redirect Code?

301 redirects in wordpress

301 redirect or HTTP code 301 is a common HTTP status code that a server sends to your browser. This is a good way to permanently redirect a URL simply, quick, and SEO-friendly. In fact, this redirect code enables you to transfer visitors from the requested URL to the alternative one.

When we should use 301 redirects in WordPress?

For example, you can use the 301 redirect code when you move your website to a new domain and want to point the user to this new address. You can also redirect the users when you wish to delete a post or want to change the permalink of your post or page.

A 301 redirect can be implemented in several ways, like writing codes or using related plugins. WordPress Redirection plugin is the most popular redirect manager that is designed to be used on sites with a few links. It not only allows you to set up redirects but also helps you to find 404 errors in your WordPress site.  Using this plugin is simple.

Start Blogging Start Blogging

Self-host your WordPress on top-tier hardware, featuring NVMe storage and minimal latency around the world — choose your favorite distro.

Get WordPress VPS

How to Set Up 301 Redirect using Plugins?

You just need to perform the following steps:

  1. Install the plugin.
  2. Activate the plugin.
  3. Now, go to the Setting in WordPress Admin menu and click on Website Redirect.
  4. Enter the URL you want to redirect the selected page to.
  5. Set the desired redirection type.
  6. Set the status to Enabled and save the changes.

Note that, the configuration of the redirection plugin can either be temporary or permanent. But, it is recommended to start with a temporary setting.

You can also perform a 301 redirect in htaccess. This method helps you to redirect URLs (it can be used both for redirecting a few links and redirecting all of the URLs) using your site’s htaccess file. But do you know how to set up 301 redirects?

How to Set Up 301 Redirect using htaccess in WordPress?

301 redirects using htaccess file

Using the .htaccess file of your site is one of the most common ways for performing 301 redirects. You can find this file in the root folder of your site.

But remember, it is very important to back up your .htaccess file before making any changes because any small mistake in coding can result in an Internal Server Error, and make your site inaccessible.

Using the cPanel File Manager, you can easily create or access the .htaccess file. Note that htaccess is a hidden file, so you need to configure an FTP client or cPanel File Manager to see the hidden files on your system. To do so, see the instruction below:

  1. Go to the cPanel of your WordPress site.
  2. In the Files section of the cPanel, click on File Manager.
  3. Now, click on the Settings button at the top-right pane of the opened window.
  4. In the Preferences window, leave the Show Hidden Files option checked, and click on Save.
  5. The File Manager window now shows all files, including hidden ones. So, search to find public_html and double-click on it.
  6. In this section, you can see the contents of public_html. You should look to find the .htaccess file. Remember, there isn’t a .htaccess file for a new site, so you need to create one. We should also mention that if your site isn’t running on an Apache Webserver, then you can’t see the .htaccess file (i.e. only Apache servers use .htaccess).
  7. Now, click on the +File button at the top left.
  8. In the newly opened window, enter the name of your .htaccess file and click on Create New File.
  9. You can see the .htaccess file. Click once on it to select it, then click on Edit.
  10. In the Text Editor dialogue box, scroll down and make sure UTF-8 is selected. Then, click on the Edit button.
  11. In the window that opens, enter the name of the page or domain that you wish to create a 301 redirect htaccess for.
  12. Now, save the changes, and close the Text Editor window.

Note: after updating or adding the .htaccess file, if the site doesn’t work, then restore site functionality by removing or renaming the file.

Start Blogging Start Blogging

Self-host your WordPress on top-tier hardware, featuring NVMe storage and minimal latency around the world — choose your favorite distro.

Get WordPress VPS

In the following, we will show you some short pieces of code that can perform various kinds of redirect for your WordPress site:

The script for Redirecting to a New Domain

To create 301 redirects in htaccess, place the following code into your htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$ RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
</IfModule>

Repeat this shortcode for every page you are going to redirect.

The script you need to Redirect to New Page

To redirect a single page to a new location on the same domain, add the following code to the .htaccess file.

Redirect 301 /old/old.htm http://www.domain.com/new.htm

Executing this code can result in WordPress Redirect Page.

The script to Redirect HTTP to HTTPs using .htaccess

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Redirecting a Specific Domain from HTTP to HTTPS

RewriteEngine On RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC] RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Redirecting a Specific Folder from HTTP to HTTPS

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} folder RewriteRule ^(.*)$ https://www.yourdomain.com/folder/$1 [R,L]

Important: these codes and instructions are used for Apache web servers only.

✅Top 4 WordPress Redirect Plugins

If you are not comfortable with using 301 redirects in the htaccess file and writing a code, then another way can be using WordPress redirect plugins. We introduced the Redirection plugin at the beginning of this tutorial. Now, it’s time to tell you about a few more plugins that can help you in redirection:

1. RankMath SEO

RenkMath SEO is one of the best WordPress Plugins that are related to redirection. It can help you both in managing redirects and improving the SEO of your website. For redirection in this plugin, you just need to add a source URL and a Destination URL. So, find the redirections in Rank math’s Sub Menu. Click on it, select the redirection type, and activate it. On the Add Redirection window, click on the button that says Add New. Here, your redirect creates.

RankMath is a lightweight plugin, with an intuitive interface for beginners. You can easily set up HTTP redirects. Using this plugin, you can easily activate or deactivate redirects. It is a free plugin with awesome support that offers a number of optional modules.

2. Easy HTTPS Redirection

You can download this plugin using the WordPress repository. It can help you create an HTTP redirection that can be set up automatically. But remember, you can use this plugin only once you have an SSL certificate installed on your website.

3. Quick Page/Post Redirect Plugin

It is one of the top-rated WordPress plugins that can manage redirections on your website, quickly. All you need to do is mentioning the request and destination URL. Using this plugin, you can easily specify 301 and 302 redirections, so that there aren’t any 404 errors on your website.

4. Yoast SEO Redirect Manager

This plugin is a real lifesaver. Using Yoast SEO Redirect Manager, making a redirect becomes a straightforward process. For example, you can do the redirect process for deleting a post with the following steps:

  1. Open the post that needs to be deleted.
  2. Move it to the trash.
  3. Choose “if it should receive a 410 content deleted redirect or a redirect to another page”
  4. Hit

🎉Congratulation. You easily managed the redirection of your WordPress site using Yoast SEO Premium.

Conclusion

301 redirects in WordPress let users, and browsers (or search engines) know that the requested URL has been permanently moved or replaced. This article covered a few methods for redirecting like coding and introduced a few redirection plugins. Now, you can easily redirect domains, pages, folders, or URLs by using WordPress Plugins or coding into the htaccess file.

In this article, we explained HTTP code 301, and HTTP to HTTPS redirection. If you are curious about PHP redirect 301, or PHP redirect to another page, please share what you know with other users in the comments. Also, if you have any questions, please feel free to ask. We will be happy to help.

Start Blogging Start Blogging

Self-host your WordPress on top-tier hardware, featuring NVMe storage and minimal latency around the world — choose your favorite distro.

Get WordPress VPS

FAQ

Should I Enable the 301 .htaccess redirect?

This option is disabled by default. If you need to change the URL of a page then, it is the best option. Thanks to the speed of the redirection. So, we advise you to enable it and help your site to shine.

What Are the Most Common Redirects?

The three most common redirects are 301, 302, and Mata Refresh. The 301 HTTP code is used for a permanent move, the 302 redirect is good for temporary Found or Moved, and Meta Refresh is good for execution on the page level rather than the server level.

What Does HTTP Redirect Mean?

It is a way for forwarding search engines and users from one URL to another one. It can be used when you want to delete a page, changing a domain name, or merging websites.

An SEO-Specialist who loves digital marketing and has a background in creating content. Matt loves teamwork and enjoys working with professional people. He always tries to bring more things to the team.

Comments

Leave a Comment

Your email address will not be published. Required fields are marked *


Latest Posts