Using htaccess for SSL redirecting to https domain folders files

After cracking my heading for whole 3 hours I finally got to get the right htaccess code to direct the payment folder for a clients site to SSL secure platform – yes https connections.

Now I want to share the codes with you so that you don’t waste time and energy on that and help cutting out on green house¬†emissions. lolz

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

If you want to redirect some particular folder to https version like

http://yoursite.com/securefolder/  to https://yoursite.com/securefolder/ then use this code on you htaccess file.


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

You can use the above code in the root htaccess file of your sites without any problem.

In case you want a different htaccess file in some particular folder then you should consider this alternative . Replace the last line of above code by this line.

RewriteRule ^(.*)$ https://yoursite.com/securefolder/$1 [R,L]

I will update more about this when I face problems regarding SSL redirections using htaccess. Till then if you have some problem implementing SSL redirections then do comment below.

More posts you might be interested in: