DOCS Add note about applying forceSSL to non-live environments

This commit is contained in:
Garion Herman 2019-11-25 12:14:26 +13:00
parent 559f660e0e
commit bf38997b6e

View File

@ -711,6 +711,19 @@ if (!Director::isDev()) {
}
```
`forceSSL()` will only take effect in environment types that `CanonicalURLMiddleware` is configured to apply to (by
default, only `LIVE`). To apply this behaviour in all environment types, you'll need to update that configuration:
```php
use SilverStripe\Control\Director;
use SilverStripe\Control\Middleware\CanonicalURLMiddleware;
if (!Director::isDev()) {
CanonicalURLMiddleware::singleton()->setEnabledEnvs(true); // You can also specify individual environment types
Director::forceSSL();
}
```
Forcing HTTPS so requires a certificate to be purchased or obtained through a vendor such as
[lets encrypt](https://letsencrypt.org/) and configured on your web server.