问题
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.
回答1:
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]
来源:https://stackoverflow.com/questions/38349915/redirect-all-subdomains-from-http-to-https-using-htaccess