tags:

views:

94

answers:

1

Hey there,

I have created an .htaccess files that will prevent anyone from accessing a file unless he has a username and a password, how can I log files when anyone tries to access with incorrect information and then ban the Ip address.

I know it in php but .htaccess i am still new to it.

Thank you everyone.

+2  A: 

You could use ErrorDocument 401 /log_request.php to send all those requests to some PHP script.

Take a look at this tutorial for more info: http://www.askapache.com/htaccess/htaccess-htpasswd-basic-auth.html

Edit: if you simply want to ban and nothing else than I would recommend using http://www.fail2ban.org/

WoLpH
i wanted to ask you after i added ErrorDocument 401 /log_request.phpi get an error Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Mahmoud
That is the default 401 error: http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html#status-401Perhaps the path is not correct?
WoLpH
Problem fix my mistake, the i location of my file was in the wrong place my mistake sorry and thank you
Mahmoud