如何将HTTPredirect到HTTPS在同一个httpd?

这是我得到的:

  • CentOS 5.4(32位)
  • 安装Apache httpd(服务器版本:Apache / 2.2.11(Unix))
  • mod_rewrite已经呈现

问题:如何将简单的http://site.comredirect使用VirtualHost定义的https://site.com ?

PS:试图find后来在SF的答案,但没有find很好的解决scheme。

谢谢。

RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

您可以使用mod_alias和基于目录的redirect 。 链接的文件标识更多的细节。

 <Directory /path/to/site> Redirect /service https://foo2.example.com/service </Directory>