- 我在 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 方案?
最佳答案
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^prod.yourdomain.com$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
现在只有 prod.yourdomain.com 会被重定向到 https。
关于php - Symfony3(或 htaccess)仅在特定的基本 url 上强制执行 HTTPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43068156/