简体   繁体   English

Symfony3(或htaccess)仅在特定基本URL上强制实施HTTPS

[英]Symfony3 ( or htaccess) enforce HTTPS on specific base url only

  • I have the same Symfony3 code base running on 2 servers (urls). 我有在2个服务器(URL)上运行的相同Symfony3代码库。
  • Both use the PROD environment and DEV environment gets used by myself for debugging. 两者都使用PROD环境,而DEV环境被我自己用于调试。
  • The one has an SSL certificate and requires all routes to be forced to the https scheme. 一个具有SSL证书,并且要求将所有路由强制设置为https方案。 The other does not and requires the normal http scheme. 另一个不需要,并且需要正常的http方案。
  • http://symfony.com/doc/current/security/force_https.html explains how to force all routes to https via security.yml http://symfony.com/doc/current/security/force_https.html解释了如何通过security.yml强制所有路由到https

Is there a way that I can implement it so that the https scheme is enforced for base url A but not for base url B, other than maintaining two separate security.yml files? 除了维护两个单独的security.yml文件之外,有没有一种方法可以实现,以便对基本URL A强制实施https方案,而不对基本URL B强制实施https方案?

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

Now only prod.yourdomain.com will be redirected to https. 现在,只有prod.yourdomain.com将被重定向到https。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM