How to Setup a Permanent 301 Redirect from One File to Another Using .htaccess

How to Setup a Permanent 301 Redirect from One File to Another Using .htaccess

When you get a 404 error, the best solution is to redirect your old page to a new page. For WordPress users, the easiest solution is to use a redirection plugin.

But as WordPress experts suggest, you should avoid using extra plugins if you can accomplish the task without using any.

Even if you’re a non-techie user, you can understand the concept and apply it to your WordPress website. For example, if you have created a page with a permalink “new tips and tricks,” and later one, you decide to modify the URL to make it SEO friendly.

In such a situation, you get a 404 error, for which, you need to set a 301 permanent redirection so that Google can come to know that the page has been shifted to a new URL.

Managing the redirects is essential to keep your SEO score intact. If you’re already using any plugin to make redirections, you can use it. Otherwise, the best decision is to use the .htaccess file.

In this tutorial, I am going to walk you through a convenient process, which can help you manage all of your redirects efficiently.

Have You Tried Using .htaccess to Set Up a 301 Permanent Redirection

If you have noticed before, .htaccess is one of the essential files of your WordPress website. While managing an error-free site, you must learn to use and edit the file.

Whether you need to increase the default file upload limit or fix the memory exhausted error, you can rely on the .htaccess file.

Follow the steps

Step 1:

Open the cPanel account your web hosting company has provided.

Start looking for the file manager. Many companies have it as a separate identity.

But if you any of the significant web hostings like Bluehost, Siteground, Inmotionhosting, etc., you can find it under the Files’ section.

Don’t worry, if you see different options.

Step 2:

It’s possible that you see a blank directory or the home directory, it’s because, by default, cPanel displays such a directory.

As you know, if you run only one domain, the data resides in the public_html directory. Make sure you’re in the root directory, you can open it from the vertical left-hand sidebar.

Search for the .htaccess file.

Note: If you don’t see the .htaccess file, it’s because the file is a hidden file and you’re haven’t ticked the checkbox from Settings showing at the top-right corner.

Step 3:

Right-click to edit and a popup appears. You can also use the Edit link showing on the main navigation menu of cPanel.

On the popup, you need to click on the Edit button.

Step 4:

A new tab appears to you on the browser where all the redirect codes are available. You need to redirect a single page to a new page.

For example, your old page is https://yoursite.com/old-page.htm, and the new page is https://yoursite.com/new-page.htm. The redirect code is as below.

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

You may be wondering about the .htm page/file extension. Well, it varies depending on the technology you use, don’t worry about it, but make sure it’s same for both the pages.

When you direct a single file to another, the above code works only when both domain name is the same.

If you change the domain, the code is different. For example, if your old page is https://yoursite.com/old-page.htm and the new page is https://yoursite.net/new-page.htm, then the code becomes as follow.

Redirect 301/old-page.htm/ https://yoursite.net/new-page.htm

Depending on your requirements, you can change the redirection code. The example consists of a different domain name with a .net extension.

You use such a code to redirect when you change the domain name. You may have read it to redirect a page to an external domain, such a task requires the last code.

I Hope It’s Easy to Make a 301 Permanent Redirect

Whenever WordPress user notices a 404 error, they freak out. Although the search engine doesn’t consider it as a bad error, if you find so many broken links, those can put a negative impact on your site’s SEO.

Making 301 permanent redirect shifts the old page to a new destination. It’s a one-time action and you don’t need to check it again and again.

When you delete or shift your old page, you should know, the page has already been indexed into Google, you can’t play it like a go forth and away game.

Conclusion

If you’re scared, you can consider a free WordPress plugin to set up a 301 permanent redirection. But sometimes, when you deactivate all the plugin, the redirection disappears.

So, it’s better to use the .htaccess file, add the code once, and forget about it. I hope you can accomplish it in an ease.

Check out these top 3 WordPress hosting services:

A2 Hosting
$2.99 /mo
Starting price
Visit A2 Hosting
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.8
  • Pricing
    4.0
IONOS
$1.00 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
HostArmada
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0

How to Set Up a 301 Permanent or 302 Temporary Redirect Using cPanel

This how-to guide provides a step by step process to set up a 301 permanent redi
3 min read
Arvind Singh
Arvind Singh
Hosting Expert

How to Redirect All Blog Posts From HTTP to HTTPS Without Using a Plugin

This how-to guide explains a method to avoid a plugin for redirecting all the bl
3 min read
Arvind Singh
Arvind Singh
Hosting Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top