How to Set up 301 Redirect in WordPress with .htaccess?

0
1072
301 Redirect

You want to redirect a URL without losing SEO traffic or value to your site/blog, but how do you get started?

There are different types of redirects that you can use, some work better than others, and some require more technical seo knowledge to get working.

But the truth is that even if you’ve found 301 redirection is challenging, you can make it work, and I’ll show you how.

Let’s get started

What is a Redirect?

URL Redirect or URL forwarding is a process that is used to redirect your (URL/Page) visitors to a separate (URL/Page).

What is Redirects

Redirects use status codes specified in the HTTP protocol, as HTTP Protocol is about communication between web clients and servers. 

Types of Redirects

  1. 301 – Permanent Redirect
  2. 302 – Temporary Redirect

What is a 301 redirect?

301 redirect is a permanent redirect from one domain/page to another domain/page. 301 redirects mean that the page has redirected to a new location permanently. With the help of 301 redirect both users and search engines are pointed to the correct page.

What is a 302 redirect?

302 is temporary redirect it gives signals to the search engines that this page/URL is redirected to another page is temporary.

Which is better 301 or 302 redirect?

If you want to move content from one page to another page permanently, then use 301 redirects.

Do 301 redirects hurt seo?

Let’s understand with an example, 

Let say you want to rebrand your website. You purchased the new domain. Now you want to move your old domain to a new domain permanently. Then there are no benefits using 302 redirects instead of using 301 redirects. And 301 redirects pass up to 90% link equity (PageRank) to the redirected page and are best for seo.

Are 302 redirects bad for SEO?

If you want to move content from one page to another page temporarily then use 302 redirects.

Let’s understand with an example, 

Let say you you have a page where you want to do some changes. So you don’t want to show your visitors a 404 page. So while making changes you can redirect your page visitors to another page temporarily. Hence instead of 301 redirects, you can use 302 redirects for a temporary basis.

As google Google spokesperson Gary Illyes also confirmed on twitter that all 300 level server-side redirects pass PageRank. 

Gary Confirm on Twitter 30x pass page rank

So you don’t need to worry about passing link equity through 301 or 302.

Use the redirects carefully, as I said above.

How to do a 301 redirect?

Let me show you how

There are many ways to do a 301 redirect, but one of the most standard methods is through changing .htaccess file.

Note – Make sure your web server should be Apache, if you are using other servers then this method will not work. Only Apache server use .htaccess.

What is the .htaccess File?

The .htaccess file is a crucial WordPress file and used to handles configuration changes on a per-directory basis.

Basically .htaccess file is used for WordPress security even you can assign special permission for particular files, configure password protection, and block spambots well.

And through .htaccess file, you can set up a URLs redirection issues or also fix broken permalinks issue as well.

How You Create & Edit .htaccess File in WordPress?

As you install the WordPress on your Apache web server, you can find the .htaccess in the root directory.

Sometimes it does not exist, so you don’t need to be panic.

You can create the .htaccess file manually in WordPress.

Let me explain – 

  1. Log into your Cpanel.
  2.  Head Over to File Manager.

File_Manager-in_Cpanel

3. Go to the public_html folder and click the New File icon at the top of the page. Then, name the file .htaccess.

.htaccess file in wordpress

4. Open the new WordPress & paste the below code.

.htaccess code in wordpress

5. Hit Save & Close.

Here is the code for your WordPress .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Want to know the best part?

So stick with me here.

Because I’m going to show you

How to Setup 301 Permanent Redirect using .htaccess?

Here’s all you have to do is : 

  1. Login into your Cpanel.
  2. Find the File Manager in CpanelFile_Manager-in_Cpanel
  3. Select the Public_html Folder

Edit_htaccess_in_Cpanel

4. In the Left Pane, you will see .htaccess fileedit_htaccess_file5. Right-click and click on edit

Add the following code into your .htaccess file To make the

301 redirects htaccess from www to non-www

RewriteEngine On
RewriteCond %{HTTP_HOST} www.yourwebsitehere.com
RewriteRule (.*) http://yourwebsitehere.com/$1 [R=301,L]

Add the following code into your .htaccess file To make the

301 redirects htaccess from non-www to www

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

301 redirect htaccess HTTP non-www to HTTPS www

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

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]

Note – Make sure you must have an SSL Certificate otherwise you will get an “Not Secure” message.

301 redirect htaccess old domain to a new domain

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldsite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldsite.com [NC]
RewriteRule ^(.*)$ https://newsite.com/$1 [L,R=301,NC]

301 redirect htaccess old page to a new page

Redirect 301 /old-page.html /new-page.html

Note – Make sure to review your .htaccess file code before making any changes otherwise your website will be in trouble.

How to do a 301 redirect in WordPress?

  1. Login in to your wordpress Admin
  2. Click on the Plugin >> Add New

Plugin Installation in WordPress

3. In the Search, Box enters redirection here.

4. Click on Install and Activate it.

Download the WordPress 301 Redirection Plugin.

Install 301 redirection plugin in wordpress

5. Head over to Tools & Click on Redirection.

Redirection_Plugin_Wordpress

6. In the Plugin Page Click on Add New a window will appear.

Source URL – Add the URL which you want to redirect.

Target URL – Add the New URL where you want to redirect your user.

301 Redirection in WordPress

And click on Save.

When to use 301 redirects?

#1. You are implementing an HTTP-to-HTTPS on your website.

Moving Site From HTTP To HTTPS

#2. You are moving your OLD Domain to a NEW Domain name.

Moving OLD Domain To New Domain

#3. There are many URLs used to access your site. Now pick a single URL as a preferred version and redirect all other URLs to this preferred URL.

Multiple versions are accessible

#4. If you have too many 404 dead pages and these pages have authority and too many links, you can use 301 redirections to move these pages authority and link juice to new relevant or less authoritative pages.

Too many 404 Pages on your site

#5. Redirect chain happens when two or more redirects between the primary URL & destination URL. Fix the redirect chain issue with reducing redirect with implementing 301 redirects in .htaccess file.

Redirect Chain Issues

#6. Pages that are redirected to broken or dead pages. Fix these pages by implementing 301 redirections.

Broken Redirects

#7. Multiple pages with Keywords Canbilaization issues. To solve the cannibalization issue make a single page with the targeted keyword. And for the rest of the pages use 301 redirects to that single page. It will help that page in passing link equity, and ranking passing power as well.

Keywords Canbilaization

301 Redirect Seo Benefits –

301 redirect is search engine friendly redirect as it tells the search engine bots that the page has been moved to new location and search engine instantly start indexing the new page.

301 redirects are not only beneficial for navigational purpose, but it also helps in seo.

Proper 301 redirection provides great user experience and also helps in distributing proper link juice in between the pages.

So don’t use 301 permanent redirects for temporary pages. Otherwise, you will lose all the link equity, authority, and reputation of the original page.

Use the 302 temporary redirect only where the move to a page is for a short period or a temporary basis.

You can use this redirect checker tool to identify your redirects errors.

Reduce errors and improve your site ranking & traffic by correctly implementing 301 redirections.

Let me know in the comments if you found any difficulties in setting up redirects I’ll help you out. If you have any questions also drop your message in the comments. I would happy to help you out!

SHARE
Previous articleHow To Add FAQ Schema in WordPress in 2 Minutes?
Next articleLearn How To Create & Optimize Your Robots.txt File For SEO
Pankaj
Pankaj Sharma is a digital marketer, writer, and love to write on SEO and various digital marketing niches. He is around more than 4+ years of experience in SEO and digital marketing field. He loves to share the knowledge and always loves to help others to get succeed.

LEAVE A REPLY

Please enter your comment!
Please enter your name here