【问题标题】:Force HTTPS on certain URLs在某些 URL 上强制使用 HTTPS
【发布时间】:2015-06-22 16:12:27
【问题描述】:

我们有一个需求,我们需要在 apache 中编写两个重写规则。

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

我怎样才能实现它。

【问题讨论】:

    标签: apache http mod-rewrite https


    【解决方案1】:
    RewriteEngine on
    RewriteCond %{HTTPS} !on
    RewriteCond %{HTTP_HOST} test.com
    RewriteRule ^(.*) https://%{HTTP_HOST}$1
    

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

    【讨论】:

      猜你喜欢
      • 2012-07-11
      • 2015-07-30
      • 2011-03-19
      • 2011-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      相关资源
      最近更新 更多