Search The Hostwinds Guides Knowledge Base

Set a Permanent (301) Redirect Using .htaccess

Share:

In the never ending race to have a relevant easy to navigate site with quality content that helps drive traffic you may find yourself needing to redesign your site or rebuild it from the ground up using a different domain name. Or perhaps you’re simply wishing to expand or diversify your web presence/brand by utilizing a new domain name that still links to some of the content from your other website. Whatever the scenario, at some point you may find yourself in need of a way to redirect content from one location to another, this is where Redirects come in. In another article we discussed how to Set A Temporary (302) Redirect Using .htaccess, however, the focus of this article is to teach you how to set a permanent redirect using that same all powerful .htaccess file.

 

How Do I Create A Permanent Redirect?

Although there are a few ways to redirect a website, such as through a website’s actual code, we will be showcasing how this is accomplished using an .htaccess file. If you have not already created an .htaccess file go check out our guide: Creating and editing an .htaccess file. That guide also covers some methods available to edit your .htaccess file. With your .htaccess file in hand (figuratively speaking), open in an editor of your choosing, you’d use the following code to redirect your entire website/domain to a new website/domain.

 

 

 

Or

 

 

 

You can also redirect your website/domain name to its www variation using the following:

 

 

 

If you’re using an SSL and you’d like to force your site to always load with the SSL add this code to your .htaccess:

 

 

 

You can even redirect the www address of your site to the non www address like so:

 

 

 

There are other variations of redirection rules/code, however these are generally the most commonly used. Don’t forget to save your .htaccess file once you’re satisfied with the edits that you have made.

 

If you have access to cPanel, you can create 301 redirects in your .htaccess file by using the Redirect option under Domains

 

Related Articles


Share:

Leave a Reply

Your email address will not be published. Required fields are marked *