Using htaccess for SSL redirecting to https domain folders files

March 13, 2011

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.

Latest Posts

Rooturaj Pattanaik

Technology & Business Consultant with customers across 6 countries. A doting father and loving husband writing about various topics like Technology, Travel, Society, Digital marketing, Investment consulting etc.

MY DICTIONARY PROJECT

I have started a new project called the Indic Dictionary. This will cover popular household words in India and what they are called in various languages. Eventually, I will make this an easy to use app where where people can easily find something like “hing in English” or “Tea Tree Oil in Hindi” or “carrom seeds in Urdu”.
Previous Story

Chitika Ads not displaying on my site / blog

Next Story

Disable Javascript | Chrome Browser | Enable Javascript

Latest from Programming

Go toTop

Don't Miss