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.

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

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.

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

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.

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

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.

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

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, and the new page is 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 and the new page is, then the code becomes as follow.

Redirect 301/old-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.


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:

Was this article helpful?