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 site.ru/login and admin site.ru/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.com/doc/2.0/book/security.html#basic-examp...

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

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

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

access_control:
 - { 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 private.zip

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

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