Force Websites to HTTPS (SSL) Connection with .htaccess and web.config
Even if you have installed Let's Encrypt or a paid SSL certificate on your website, when visitors type your site's address directly into the browser, they will automatically receive an outdated and insecure certificate.http://It can be opened with the protocol. To ensure that your site does not lose value in search engines (SEO) and that it always has a secure green lock (https://In order to open with ), you must perform a server-based permanent redirect (301 Redirect).
Method 1: For Linux / Apache / Litespeed Servers (.htaccess)
To activate redirection on Linux-based servers (cPanel, HestiaCP, DirectAdmin, etc.) .htaccess Open the file and add the following codes to the top line:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Method 2: For Windows/IIS Servers (web.config)
On servers using Windows Server-based Plesk or IIS panel, the directory in the home directory for redirection web.config by opening the file<system.webServer>You should include the following rules between your tags:
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
This article is specially prepared for PvPServer.