How to redirect HTTP to HTTPs in .htaccess

Today’s standard is to have an https certificate. Google will love you if your sites are secured. So https is not standard, it’s must-have! Easy way to make your website secured is making a redirect from HTTP to HTTPS in the .htaccess file.

33.2% of Alexa top 1,000,000 websites use HTTPS as default, 57.1% of the Internet’s 137,971 most popular websites have a secure implementation of HTTPS, and 70% of page loads (measured by Firefox Telemetry) use HTTPS. Statistics are from April 2018.

Source: Wikipedia

Redirect HTTP to HTTPs in .htaccess

Using this code to successfully redirect your domain from http to https is the easiest way:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Using the 301 'permanently moved' redirect will help transfer your SEO rankings. To redirect using the 302 'temporarily moved' change [R=302,L]

Redirect HTTP to HTTPs with a plugin in WordPress

If you are not familiar with .htaccess, you can use a plugin Really Simple SSL. The plugin has no complicated settings, but for this problem it’s overkill.

Recent Articles

How to Hide Shipping Methods in WooCommerce?

This is a small detail, but WooCommerce doesn't have built-in any function for hiding shipping methods based on different situations. Imagine when...

How to Get WordPress Post Featured Image URL

Are you a WordPress developer or an advanced WordPress user? Whoever you are, sometimes you may need the direct URL of a...

How to Bulk Delete Media in WordPress

WordPress and media. That's the topic for a book. Sometimes is not easy to find what you need and when you have...

Custom Order Number for WooCommerce Will Saves You a Lot of Hassle!

WordPress is still the king of Content Management Systems (CMS). Thanks to its open-source nature, millions upon millions of users and PHP...

How to Manually Sort WooCommerce Products

WooCommerce is an e-commerce plugin for WordPress. It is a great way for the user to create an online store for their...

Get in touch

Be our first-class reader, build a community and follow us on social media!

Leave A Reply

Please enter your comment!
Please enter your name here