RewriteRule不能用于Apache https请求

我们有要求将所有http请求转换为https请求,并将.xyz.com附加到服务器名称。 为此,我写了下面的规则,这是为HTTP请求工作,但不适用于https请求。

RewriteRule ^(.*)$ https://%{SERVER_NAME}\.xyz.com%{REQUEST_URI} [R] 

如果inputhttp:// lvldraspnetserv01,则会根据需要redirect到https:// lvldraspnetserv01.xyz.com。

但是,如果我键入https:// lvldraspnetserv01,则不会redirect到https:// lvldraspnetserv01.xyz.com,导致证书失败。

试试像这样:

 RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} **Insert current condition here *** RewriteRule ^(.*)$ https://%{SERVER_NAME}\.xyz.com%{REQUEST_URI} [R] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} **Insert current condition here, but for https*** RewriteRule ^(.*)$ https://%{SERVER_NAME}\.xyz.com%{REQUEST_URI} [R] 

我有同样的问题。

添加QSA标志解决了这个问题

 RewriteRule ^(.*)$ https://%{SERVER_NAME}\.xyz.com%{REQUEST_URI} [R, QSA] 

奇怪的行为不是吗? :)^^