Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 2: Force https for all routes [closed]

Tags:

http

php

symfony

I have made a web application in the symfony 2 framework. This is working fine but now i want to change the http:// to https:// for all the routes!

And how can I check if my environment is localhost in this. If I work locally I want to use the normal http://.

Where to set this, i can't find it?

Thanks!

like image 929
Thomas Crawford Avatar asked Feb 20 '15 12:02

Thomas Crawford


1 Answers

Here you go: (Not tested but should work.)

# app/config/security.yml
security:
    # ...
    access_control:
        - { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https, host: yourdomain\.com$ }
        - { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: http, host: localhost$ }

http://symfony.com/doc/current/cookbook/security/access_control.html#forcing-a-channel-http-https

like image 177
Markus Kottländer Avatar answered Oct 26 '22 23:10

Markus Kottländer