How to do a 301 Redirect in an .htaccess file

The server response code (i.e. 301 v.s 302) can have a significant impact to the crawlers and bots that crawl your site. I wrote about that in some detail in an article titled, “What is the difference between 301 and 302 redirects in SEO?

But the purpose of this article to simple outline how to add a 301 redirect to your .htaccess file, not explain server response codes.

Here is the 301 redirect code of the .htaccess file:

Redirect 301 /oldpage https://www.domain.com/NewPageURL

You would replace “oldpage” with the relative path to the page that you are wanted to direct traffic from and then replace “https://www.domain.com/NewPageURL” with the absolute path of the URL that you are wanting to send that traffic to.

.htaccess Redirect Tips

  1. The spacing is important
  2. The “/” before the relative path is important
  3. 1 redirect command per line