I have folder /admin/index.php how to restrict access to that folder except logged user. I try to restrict access with .htaccess but it restrict access at all
On your /admin/index.php are you checking these things:
Seems like the logical way to tackle this.