How to ignore https if its localhost?

155 Views Asked by At

I actually know how to force redirect to https or to http if its local, like below:

security.yml

 ...
 - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: http, host: localhost$ }
 - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
 ...

but the problem is that, I have alot of redirections.

Is there easy way to ignore https for localhost? I couldn't find anything on symfony homepage or on google.

or is it something like below possible?

- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https, host:!localhost$}

is it possible to ignore host?

1

There are 1 best solutions below

1
On

try to modify .htaccess file and use server_name to check if localhost:

RewriteEngine On

RewriteCond %{HTTPS} ==on

RewriteRule .* http://%{SERVER_NAME}%{REQUEST_URI} [R,L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ app.php [QSA,L]

check example here or here