You can use these rules in 2 VirtualHost
sections:
<VirtualHost *:80>
ServerName myServer.com
ServerAlias www.myServer.com
DocumentRoot "/var/www/html"
RewriteEngine on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
</VirtualHost>
<VirtualHost *:443>
ServerName myServer.com
ServerAlias www.myServer.com
DocumentRoot "/var/www/html"
RewriteRule ^/Maintenance/([^/]+).html?$ /?q=$1 [QSA,NC,L]
RewriteRule ^(.*).ht$ /?q=$1 [NC,L,QSA,CO=RewriteRule;01;https://www.myServer.com;30/;SameSite=None;Secure]
</VirtualHost>
It is important to keep rewrite rules in VirtualHost *:443
because port 80 one is just redirecting all the traffic to https
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…