ULIX TxT Editor on Sourceforge.net






Forcing SSL (HTTPS) with the .htaccess file


Okay, so lets say that you are a multi-million dollar producing corporation and you want to parse secure payments from your clients over they online account on your website...You have two options... The first is doing it thru a standard HTTP protocol which is fine, however it would be vulnerable to data breaching and intercepting. Or Option two... is to use a Secure HTTP protocol which will let the end-user, your clients, know that all their transactions will be safe and secure on your site and that would be to force your domain or website to be accessed only via an SSL encryption...by this I mean using an HTTPS protocol.



For an entire domain name


You can force an HTTPS connection on your website by adding these rules in your website's .htaccess file.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=302,L]
Simply replace the yourdomain.com with your websites domain name and it's corresponding TLD and you'll be set to go... as long as you are using a Dedicated IP address and have purchased an SSL Certificate.



For subfolder websites


If your website is in a subfolder, use this code instead:RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://yourdomain.com/folder/$1 [R=302,L]
Where yourdomain.com is your actual domain name and folder should be replaced with the name of the subfolder where your site is situated.