Once again I bring some non automotive content to Wrecked.

I was recently trying to Force a SSL connection on a folder on a site that I was developing. This sounds like an easy enough task. After a few hours of attempts that ended up sending the secure folder in a infinite loop. This was a puzzle. I followed several sets of documentation that each of them agreeing on how to handle the problem.

To force the SSL on the folder I ended up having to do this to the .htaccess file:

#Force SSL on a specific directory
RewriteEngine On
RewriteBase /dashboard/
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule ^(.*)$ https://www.websitenamehere.com/dashboard/$1 [R,L]

A simple explanation:
The .htaccess file is located in the /dashboard/ folder.

The folder we are trying to force is /dashboard/

Please note that I was trying to do this on a Rackspace Could Site. (The documentation that they provided was incorrect.)This may have something to do with the fact the normal ways for forcing the secure connection were not working. I couldn’t get rackspace to verify if the loop was being caused by their server configuration. Hopefully this post will help someone that is having the same issue with rackspace and forcing ssl on a folder.

For the record this is once of the ways that I tried but was not sucessfully at implementing. This may work on non Rackspace Cloud Servers.

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