HTTP到HTTPS重定向阿帕奇
问题描述:
的环保的Centos的与Apache
Environment Centos with apache
想设置自动重定向从http到https
Trying to setup automatic redirection from http to https
From manage.mydomain.com --- To ---> https://manage.mydomain.com
我曾尝试加入以下到我的httpd.conf,但没有奏效。
I have tried adding the following to my httpd.conf but it didn't work
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
任何想法?
答
我其实都遵循这个例子,它为我工作:)
I have actually followed this example and it worked for me :)
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mysite.example.com
DocumentRoot /usr/local/apache2/htdocs
Redirect permanent / https://mysite.example.com/
</VirtualHost>
<VirtualHost _default_:443>
ServerName mysite.example.com
DocumentRoot /usr/local/apache2/htdocs
SSLEngine On
# etc...
</VirtualHost>
然后执行:
/etc/init.d/httpd重启