如何在directadmin界面中将自定义httpd.conf代码添加到域的VirtualHosts?
我需要添加以下行以将 http 重定向到 VirtualHost 端口 80 和 443 中我的域上的 https:
<VirtualHost *:80>
ServerName www.example.com
Redirect "/" "https://www.example.com/"
</VirtualHost>
<VirtualHost *:443>
# Use HTTP Strict Transport Security to force client to use secure connections only
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
# Further Configuration goes here
[...]
</VirtualHost>
我已经用这个 htaccess 重定向解决了它:
# Redirect if http
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# set header if https
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS