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.

Add comment

Recent Posts


Recent Comments