Symfony3(或htaccess)仅对特定的基本URL强制执行HTTPS

时间:2017-03-28 11:18:54

标签: php .htaccess symfony ssl

  • 我在2台服务器(网址)上运行相同的Symfony3代码库。
  • 两者都使用PROD环境,DEV环境被我自己用于调试。
  • 该证书具有SSL证书,并要求将所有路由强制为https方案。另一个不需要正常的http方案。
  • http://symfony.com/doc/current/security/force_https.html说明如何通过security.yml
  • 强制所有路由到https

有没有办法可以实现它,以便对基本网址A强制执行https方案,但对基本网址B不强制,除了维护两个单独的security.yml文件?

1 个答案:

答案 0 :(得分:2)

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

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

相关问题