HTTP to HTTPS

 

The easiest route to redirect your website to HTTPS:// only after installing an SSL Certificate, would be to install a popular plugin such as Really Simple SSL or WordPress HTTPS.  However, if you’re trying to keep your Plugin count down on your site you can also achieve this by updating your .htaccess file with some basic coding on a Linux Hosting.  Your .htaccess file can control a lot different things with your website, so make sure to add the code at the beginning or end of any existing code so nothing breaks (and always take a quick backup before making any coding modifications).

 

Best Redirect We’ve Found

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

 

If you copy and paste this code into your .htaccess file, these 3 lines of code will redirect your web traffic to HTTPS only. Boom, no plugins!

_ _ _ _ _ _ _ _ _ _ _ _

However if this doesn’t work for you, here is some more common coding for a 301 redirect using your domain, just replace the example domain with your own.

301 Redirect Code

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?YOURDOMAINGOESHERE\.com
RewriteRule ^(.*)$ https://WWW.YOURDOMAINGOESHERE/$1 [R,L]

_ _ _ _ _ _ _ _ _ _ _ _

 

Now you might be saying to yourself, I use Windows Hosting so this isn’t working, thanks for nothing..  Don’t worry! We’ve got you covered by simply using a Web.config file instead of .htaccess you can easily redirect your site to HTTPS on Windows.

<configuration>
<system.webServer>
<rewrite>
    <rules>
	<rule name="HTTP to HTTPS redirect" stopProcessing="true"> 
	<match url="(.*)" /> 
	<conditions> 
		<add input="{HTTPS}" pattern="off" ignoreCase="true" />
	</conditions> 
	<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>   
    </rules>
</rewrite>
</system.webServer>
</configuration>

Don't forget to back up your existing Web.config file before attempting any changes.

*PRO TIP -If you are using Plesk Hosting, make sure to Enable SSL Support under Hosting Settings, and
select the Installed SSL you're using.



_ _ _ _ _ _ _ _ _ _ _ _

 

You are now an expert in 301 redirects on both Linux and Windows Hosting!  If you’re using WordPress specifically, you can also modify the Home/Site URL’s in the Settings to include HTTPS:// or update through your wp_options table in the database.