.htaccess File to Make Your Site Accessible via HTTPS Only

By | April 28, 2013

If you have a SSL certificate installed, you might want to force your visitors to use secure version of it. Sometimes you cannot modify httpd.conf, the only file that can resolve the issue is .htaccess. Let me paste the code below to help you set this up.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

This code checks if HTTPS protocol is used. If not – all parts of request URI are posted to secure version of your site.

Leave a Reply

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