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

One Reply to “How to force use HTTPS protocol”

  • Nakliye says:

    I seriously love your site.. Very nice colors &
    theme. Did you build this amazing site yourself?
    Please reply back as I’m wanting to create my own personal blog and would love to learn where you got this from
    or exactly what the theme is called. Appreciate it!

Your email address will not be published. Required fields are marked *