301-Redirect

How to apply 301 Redirect using .htaccess file?

What is 301 Redirection?

We need to apply redirection if a webpage is changed or moved to another new location which is indicated by URL Change. Actually the redirection tells your web browser that the page is moved to other new location and so the web browser must take the user to that location. There are different types of redirection. But among them, 301 redirect is very much useful and it guides the Search Engine Bots and Browser that the content is moved to New Location, permanently. As the change is permanent, it is only important for the humans who are going to access it but also important for search engines.

When Should You Use 301 Redirection?

  • Changing URL of a Single Post or Page – If you are changing the Page URL or Post URL, then you must apply 301 Permanent Redirect from the old URL to new URL. So that if a user is reaching the Old URL then they will be redirected to the new URL.
  • Consolidated Posts or Pages – If there are different posts about a single topic and if you are consolidating the three different post into the single post then you must apply 301 permanent Redirection to that single post for better understanding.
  • Change in Domain Name – If you are changing website name but with same contents, then you must apply 301 Permanent Redirection from the Old Website to the New Website.

301 redirect wordpress htaccess

How to Apply 301 Redirection with .htaccess file?

Applying 301 Redirection is very much important. If you are ranking well for various terms but changing the site structure or URL for better visibility, then it may cost your rankings. So permanent redirection will help you to gain the link juice and same ranking for the new URL. Below are the steps to apply permanent redirection in your website with .htaccess file.

1. Find .htaccess file:

You want to find and download the .htaccess file of your website. This can be done through cPanel or FTP Access of your website. Once the .htaccess file is found download it to your local PC. Once the download is completed, it is recommended to take a backup of the .htaccess file to avoid future issues.

2. How to Edit the .htaccess file?

Once the .htaccess file of your website is downloaded, open it will Notepad or Notepad++ for a clear view. As original Copy of .htaccess file is very much important, you must make sure you are not editing the backup copy of the .htaccess file.
htaccess-file

3. Add 301 Redirects

Before Editing, you must be very clear with the Old URL and Updated URL. Once confirmed then the redirection must be applied as in the below format.

Redirect 301 /old-url https://yourdomain.com/new-url

For Example: If your old URL is “https://www.seekahost.com/web-hosting-types” and New URL is “https://www.seekahost.com/different-web-hosting-types”

Redirect 301 /web-hosting-types https://www.seekahost.com/different-web-hosting-types

4. Redirect from Old Domain to New Domain

If you are applying redirection for the entire domain then you must add the below codes in .htaccess file.

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

Replace olddomain.com – Old domain name and newdomain.com – New domain name