Q:

Redirecting all of one subdomain's traffic to HTTPS via htaccess

Using .htaccess, is it possible to redirect http://www.mydomain.com and http://mydomain.com to HTTPS, while NOT redirecting http://staging.mydomain.com or http://127.0.0.1?
Also, what will happen to any POST data that goes through the redirected portion? Will it remain insecure, or will it also be encrypted?

A:

This should get you going. Once redirected by apache, all data is processed through https.
RewriteEngine On
RewriteCond %{HTTPS} !^on$
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

