Reputation: 1765
How do I redirect all subdomains of example.com
from http
to https
using .htaccess
?
I've searched Google and can't find a solution.
Upvotes: 0
Views: 4091
Reputation: 41219
To redirect all subdomains of example.com
to https
, you can use :
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^((?!www\.)[^.]+)\.example\.com$
RewriteRule ^ https://%1.example.com%{REQUEST_URI} [NE,L,R]
Upvotes: 5