Apache2 rewrite rule multiple domains/subdomains – redirect http to https

Rewrite rule for  redirecting http(80) traffic to https(443) in an apache2 server hosting/acting-as-gateway-for multiple subdomains

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*)$ https://%{HTTP_HOST}/$1 [L,R=301,NE]

Example, 

http://company.myproduct.com/someuri?param1=v1&param2=v2

gets redirected to

https://company.myproduct.com/someuri?param1=v1&param2=v2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s