Nick S.
Nick S.

Reputation: 353

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?

Upvotes: 1

Views: 134

Answers (1)

Panama Jack
Panama Jack

Reputation: 24448

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]

Upvotes: 2

Related Questions