Force SSL on linux hosting with htaccess mod_rewrite
Posted by Premium Reseller on 10 September 2015 10:35 AM

After you set up ssl for website, you want users to access website via https only.

One way to redirect all http traffic to https is add configuration in .htaccess file in website home folder.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://your-domain.com/$1 [R,L]

Replace your-domain.com with your domain.

The following configuration will force https access on specific subfolder on your website

RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} subfolder
RewriteRule ^(.*)$ https://your-domain.com/subfolder/$1 [R,L]

(0 vote(s))
This article was helpful
This article was not helpful