Review Hell Blog

This is where I post site news, tips and tricks, and special web hosting offers. Make sure you subscribe!

Subscribe to Updates

Get the latest Review Hell news, blog updates, and special offers in your inbox. No spam, promise!

Redirecting HTTP to HTTPS through .htaccess

image

Two weeks ago, Google announced that HTTPS is now a factor in determining search engine rankings. They say their reason for this is they want to help make the web safer for everyone. It’s just a “lightweight signal” for now but it’s possible that this can be a more important ranking factor in the future:

For now it’s only a very lightweight signal — affecting fewer than 1% of global queries, and carrying less weight than other signals such as high-quality content — while we give webmasters time to switch to HTTPS. But over time, we may decide to strengthen it, because we’d like to encourage all website owners to switch from HTTP to HTTPS to keep everyone safe on the web.

I got an SSL certificate for Review Hell due to this, and you can see that the whole site is now served through HTTPS. Implementing HTTPS was a breeze but I had a Google index-related issue. I had all my web pages as HTTP before, so naturally, Google’s index had my whole site as HTTP! It was therefore necessary for me to permanently move all my HTTP pages to HTTPS so that Google, other search engines, and of course my visitors would be redirected to the secure version of the site.

To redirect all traffic to the HTTPS version of your website, just include the following in your .htaccess file:

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

I recommend that you do this even for new websites. Sure, you may have submitted your new site to Google and other search engines as HTTPS (hence your site will be indexed as such), but other people may bookmark or link to the HTTP version of your site and this could cause duplicate content issues.

P.S. Make sure that all your content, including images and other media files, are served in HTTPS so that your site won’t spew out warnings that say a certain page is not totally secure. You may have to change all your links manually, but fortunately for WordPress users there’s a plugin that can do the job for you: click here. Enjoy!

Share this post!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.