Redirect HTTP to HTTPS automatically

Redirect HTTP TO HTTPS
Redirect HTTP TO HTTPS

Redirect HTTP to HTTPS automatically

Redirect HTTP TO HTTPS: –Hi Readers, If you have recently purchased SSL for your website to make it secure and want users to redirect HTTP website  to HTTPS automatically then you are at right place to configure it very easily.To do it we have to force the browser to redirect to HTTPS (secure) site.

You can purchase SSL certificate from any reputed hosting like Godaddy and big rocks.SSL websites are very secure and users can trust on your website and feels secure.It helps to improve the ranking of a website in search engine.Nobody can steal your essential information like login details, credit/debit/net banking card details and cookies information.Here we continue topic on Redirect HTTP TO HTTPS

For LINUX Hosting.

Linux hosting and Apache server use .htaccess file to handle redirection of a website.In this file, we use below code to redirect a website to secure website.

If your website is built on WordPress then you may have already a .htaccess file if not then you can create a .htaccess file inside root folder(public_html/www/HTTP docs) of a server.Copy below code and paste in .htaccess file to Redirect HTTP TO HTTPS

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

for WINDOWS hosting

In Windows hosting, Web.config file is used to redirect website and re-write rule

You have to create a web.config file, If already have then you don’t need to create again and write the code below in web.config file

<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>

I hope you would like this session about Redirect HTTP to HTTPS automatically

Leave a Comment