如何在apache反向代理服务器上强制将http重定向到https?
我有一个带有http和https服务的apache反向代理服务器。我想强制将http重定向到https。我应该如何配置配置文件?推荐而且更安全的方法是使用VirtualHost:如何在apache反向代理服务器上强制将http重定向到https?,apache,http,redirect,https,reverse-proxy,Apache,Http,Redirect,Https,Reverse Proxy,我有一个带有http和https服务的apache反向代理服务器。我想强制将http重定向到https。我应该如何配置配置文件?推荐而且更安全的方法是使用VirtualHost: <VirtualHost *:80> ServerName www.example.com Redirect permanent / https://www.example.com/ </VirtualHost> 正如我所说,Apache建议使用VirtualHost配置 举例如下
<VirtualHost *:80>
ServerName www.example.com
Redirect permanent / https://www.example.com/
</VirtualHost>
正如我所说,Apache建议使用VirtualHost配置
举例如下:
谢谢,它可以工作,我使用ProxyPass原版,但不起作用。
<VirtualHost *:80>
ServerName www.example.com
Redirect permanent /login https://www.example.com/login
</VirtualHost>
RewriteEngine On
# This will enable the Rewrite capabilities
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e. http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context