使用.htaccess将所有子域从http重定向到https

Ste*_*eve 0 .htaccess

如何将example.comfrom的所有子域重定向httphttpsusing .htaccess

我已经搜索过Google,但是找不到解决方案。

sta*_*een 5

要将的所有子域重定向example.comhttps,可以使用:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^((?!www\.)[^.]+)\.example\.com$
RewriteRule ^ https://%1.example.com%{REQUEST_URI} [NE,L,R]
Run Code Online (Sandbox Code Playgroud)