How to close the admin panel of the website?

Good day!
Faced with the need to close access to the admin site on Symphony. The entrance to it is from the page with login-password, but you need to isolate it from unwanted people in principle.

At first I thought to use the standard tools htaccess, but the problem is that the login page has the form and admin
Physically these directories do not exist, so put the htaccess file is not possible.
Is there any way to solve this problem?
July 8th 19 at 11:15
3 answers
July 8th 19 at 11:17
Not to spread logic in different places and not be dependent on apache, I would have used the standard tools:

 Symfony\Component\Security\Core\User\User: plaintext

 %admin_username%: a # admin_username and admin_password parameters can be set in parameters.yml
 password: %admin_password%
 roles: 'ROLE_SYNC'

 provider: admin
 pattern: ^/admin
 path: /admin/logout
 target: /admin
 http_basic: ~
 anonymous: false

 - { path: ^/admin/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
 - { path: ^/admin/administrator, role: IS_AUTHENTICATED_FULLY }
 - { path: ^/admin, role: IS_AUTHENTICATED_REMEMBERED }
July 8th 19 at 11:19
Deny access only to the file

<files admin index.php> 
AuthType Basic 
AuthName "Private zone. Only for administrator!" 
AuthUserFile /usr/host/mysite/.htpasswd 
require valid-user 
July 8th 19 at 11:21

Take a sample of the second example and change for themselves. Place code in the beginning index.php I understand that you are all through it. And put the condition that this code worked only when accessing the admin area.

Find more questions by tags PHPhtaccessSymfony