在某些URL上强制使用HTTPS

时间:2015-04-16 10:11:26

标签: apache http mod-rewrite https

我们需要在apache中编写两个重写规则。

Add new Apache rule http://*.test.com -> https://*.test.com
Add new Apache rule http://*.test.com/home/ -> https://*.test.com/home/

我怎样才能实现它。

1 个答案:

答案 0 :(得分:0)

RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} test.com
RewriteRule ^(.*) https://%{HTTP_HOST}$1

这应该适用于http:// .test.com / 。 您必须将其放入虚拟主机配置或.htaccess文件中。