在web环境搭建好lamp之后,大多数会选择给自己的网站加上https,HTTPS的好处不言而喻。
加了HTTPS之后,需要将原来的HTTP链接换成HTTPS,调整apache vhost的conf信息:
<VirtualHost *:80> DocumentRoot /var/www/html/www.shiwen.org.cn ServerName www.shiwen.org.cn ServerAlias www.shiwen.org.cn shiwen.org.cn ErrorLog logs/www.shiwen.org.cn-error_log CustomLog logs/www.shiwen.org.cn-access_log common RewriteEngine on RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [R=301,L] </VirtualHost>
配置好后记得重启apache,就能实现HTTP 301 to HTTPS了。