Not long ago, I shared a tutorial with you about redirecting www and non-www website traffic using htaccess.

One of the items I didn’t address is how to account for redirecting http and https requests.

With all of the talk about Google now factoring SSL (also known as HTTPS traffic) as a ranking factor in search ranking, there are many website owners wondering how to setup their website to use HTTPS instead of the implicit HTTP.

To setup your website to use HTTPS, you’ll need to ensure your web hosting provider and web hosting plan offers SSL certificate (not a shared SSL certificate).

Today, I’ll share with you 4 htaccess methods for redirecting http and https requests.

If you’re wanting to redirect https traffic to http, then you htaccess file should contain the following code:

If you’re wanting to redirect http traffic to https, then you htaccess file should contain the following code:

Another method for redirecting https traffic to http uses and tests the SERVER_PORT variable against PORT 443 (https):

Another method for redirecting http traffic to https uses and tests the SERVER_PORT variable against PORT 80 (http):

In addition, notice that the HTTP_HOST and REQUEST_URI server variables were used in the RewriteRule directive as well as the flags.

To learn more about server variables, go here.