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

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


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]
# 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


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}
RewriteRule (.*)$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 ^(.*)$$1 [L,R=301]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$$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} ^ [NC,OR]
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$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 into 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.


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!


  1. you are truly a good webmaster. The website loading speed is incredible. It kind of feels that you’re doing any distinctive trick. Furthermore, The contents are masterpiece. you’ve done a great activity on this topic!

  2. I like the helpful information you provide in your articles. I will bookmark your blog and check again here frequently. I’m quite sure I will learn many new stuff right here! Good luck for the next!

  3. This is very interesting, You are a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I have shared your site in my social networks!

  4. After I initially commented I clicked the -Notify me when new comments are added- checkbox and now each time a remark is added I get four emails with the same comment. Is there any means you’ll be able to remove me from that service? Thanks!

  5. you are in point of fact a just right webmaster. The website loading velocity is incredible. It seems that you are doing any distinctive trick. Furthermore, The contents are masterwork. you’ve performed a magnificent task in this topic!

  6. I do not even know how I ended up here, but I thought this post was great. I don’t know who you are but certainly you are going to a famous blogger if you are not already 😉 Cheers!

  7. Have you ever thought about adding a little bit more than just your articles? I mean, what you say is valuable and all. Nevertheless think of if you added some great graphics or video clips to give your posts more, “pop”! Your content is excellent but with pics and video clips, this website could certainly be one of the very best in its field. Superb blog!

  8. I was just seeking this info for a while. After six hours of continuous Googleing, finally I got it in your website. I wonder what’s the lack of Google strategy that do not rank this type of informative websites in top of the list. Usually the top sites are full of garbage.

  9. This is really interesting, You are a very skilled blogger. I’ve joined your feed and look forward to seeking more of your wonderful post. Also, I have shared your web site in my social networks!

  10. This design is spectacular! You definitely know how to keep a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job. I really enjoyed what you had to say, and more than that, how you presented it. Too cool!

  11. I think this is among the most vital information for me. And i am glad reading your article. But wanna remark on some general things, The web site style is ideal, the articles is really great : D. Good job, cheers

  12. I do love the manner in which you have presented this particular matter plus it does indeed supply me some fodder for consideration. However, through what precisely I have personally seen, I just simply trust when the opinions stack on that individuals keep on issue and don’t embark on a tirade of the news of the day. Anyway, thank you for this exceptional point and whilst I do not necessarily concur with this in totality, I respect your standpoint.

  13. It is appropriate time to make some plans for the long run and it is time to be happy. I have read this submit and if I may I desire to counsel you few fascinating things or advice. Maybe you can write next articles relating to this article. I desire to read even more things approximately it!

  14. I liked this article! I review your blog site
    rather frequently and also you’re constantly coming out with some terrific
    stuff. I shared this on my facebbok as well as my
    followers liked it! Keep up the great 🙂


Please enter your comment!
Please enter your name here