Force use HTTPS instead HTTP protocol

When site use HTTPS it’s very good. But sometimes site can be available use HTTP protocol. And this moment significantly mess up a generally painting of security. In order to avoid such situations we should be use force open all pages using HTTPS protocol.

How to force use HTTPS protocol

Problem: How to force use HTTPS protocol

Solution: This task can be resolved used 5 string in .htaccess file.

# Force Open HTTPS 
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

Therefore we'll have something similar to next contain:

# Force Open HTTPS 
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Leave Comment

Your email address will not be published.