【问题标题】:Symfony3 ( or htaccess) enforce HTTPS on specific base url onlySymfony3(或 htaccess)仅在特定的基本 url 上强制执行 HTTPS
【发布时间】:2017-08-21 10:40:03
【问题描述】:
  • 我在 2 个服务器 (url) 上运行相同的 Symfony3 代码库。
  • 都使用PROD环境,DEV环境自己调试用。
  • 一个有 SSL 证书,要求所有路由都强制使用 https 方案。另一个不需要并且需要正常的 http 方案。
  • http://symfony.com/doc/current/security/force_https.html 解释了如何通过 security.yml 强制所有路由到 https

除了维护两个单独的 security.yml 文件之外,我有没有一种方法可以实现它,以便对基本 url A 而不是对基本 url B 强制执行 https 方案?

【问题讨论】:

    标签: php .htaccess symfony ssl


    【解决方案1】:
    RewriteCond %{HTTPS} !=on [OR]
    RewriteCond %{HTTP_HOST} ^prod.yourdomain.com$ [NC]
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    

    现在只有 prod.yourdomain.com 会被重定向到 https。

    【讨论】:

      猜你喜欢
      • 2012-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-15
      • 1970-01-01
      • 2019-04-20
      • 2016-03-15
      • 2015-12-23
      相关资源
      最近更新 更多