How about failed attempts for htaccess password protected directories

This question is related to the previous question I asked, but it is different.

I use htaccess to control login http://somesite.com/folder.

After logging in, I have php code in folder/index.phpto check the username and password used to log in: $_SERVER['PHP_AUTH_USER']and $_SERVER['PHP_AUTH_PW']. I am logging this information in a database.

This works when the user supplies a good username and password, but when it is incorrect, nothing happens - I suppose, because it is /index.phpnever achieved.

Is there a way to login and failed login attempts?

+3
source share
2

. .htaccess

ErrorDocument 401 /path/to/log.php

log.php ( , , ). , , - , . , (, , , ), , $_SERVER['PHP_AUTH_USER'] .

, , , /index.php .

, Apache PHP. , . . , . PHP, . , , PHP. PHP, include. , PHP , , .

+4

, , , auth Apache fail2ban. !

+1

Source: https://habr.com/ru/post/1753106/


All Articles