Adam Wróbel Adam Wróbel -4 years ago 97
Apache Configuration Question

.httpaccess - redirect from http to https protocol only if I'm on the general domain

How I can redirect from http to https protocol only if I'm on the general domain (skiped subdomains). I tried using this redirect, but this is redirecting too subdomains.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Answer Source

Try with below,

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www?)\.domain\.com
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download