简体   繁体   中英

track my website visitors with .htaccess resrictions

I have a website that only few IP's have access to see (list of ip's in the .htaccess file) now i want to create some log to track the ip's that tried to get into my website and they are not allowed - not on the list. if it is possible to write every attempt to the database? and if it's not possible to know the IP , maybe just write the date and time they try to. any suggestion? thanks, Mor

Assuming you have console access and pretty much the default configurations, just issue

cat /var/log/apache2/access_log | awk '{if ($9 == 403) print $1}'

in the cli.

127.0.0.1 - - [03/Nov/2014:18:45:21 +0100] "GET /forbidden/test.jpg HTTP/1.1" 403 

The first column is the IP, and the 9th (403) is the HTTP status. Each "column" is delimited by space.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM