php-symfonyHow to force HTTPS in PHP Symfony?
To force HTTPS in PHP Symfony, you can use the following code snippet:
# app/config/config.yml
# To force HTTPS
framework:
# ...
trusted_proxies:
# ...
trusted_hosts:
# ...
session:
# ...
cookie_secure: true
cookie_httponly: true
default_locale: en
# ...
# Force HTTPS
# uncomment the following line
# base_url: https://example.com
This code snippet will set the cookie_secure
and cookie_httponly
parameters to true
and set the base_url
parameter to https://example.com
. This will ensure that all cookies are sent over HTTPS and that all requests are redirected to HTTPS.
Code explanation
cookie_secure
: sets the cookie to be sent over HTTPScookie_httponly
: sets the cookie to be sent over HTTP onlybase_url
: sets the base URL tohttps://example.com
Helpful links
More of Php Symfony
- How to install Symfony on Windows?
- How to check PHP Symfony version?
- How to create a model in PHP Symfony?
- How to integrate Vue.js with PHP Symfony?
- How to run a command in PHP Symfony?
- How to persist data in PHP Symfony?
- How to use Prometheus with PHP Symfony?
- How to get the current URL in PHP Symfony?
- How to get request parameters in PHP Symfony?
- How to implement pagination in PHP Symfony?
See more codes...