Apache 2.4 i WAMP 从 http 重定向到 https 不起作用

Apache 2.4 i WAMP 从 http 重定向到 https 不起作用

我在 Windows 中使用 wamp 服务器(Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.3.12)。我已成功安装 SSL 证书。现在 https 可以正常工作。但 http 重定向不起作用。

<VirtualHost *:80>
ServerName test.com
ServerAlias www.test.com
Redirect permanent / https://test.com/

</VirtualHost>

<VirtualHost *:443>
ServerName test.com
ServerAlias www.test.com
DocumentRoot "C:/wamp64/www/test"
<Directory "C:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile "C:/wamp64/bin/apache/apache2.4.41/conf/key/fullchain.pem"
SSLCertificateKeyFile "C:/wamp64/bin/apache/apache2.4.41/conf/key/privkey.pem"
SSLCertificateChainFile "C:/wamp64/bin/apache/apache2.4.41/conf/key/fullchain.pem"
</VirtualHost>

当我尝试使用 http 访问它时,出现了严重的请求错误。

Bad Request
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

你能帮我解决这个问题吗?

相关内容