For example in my logs I have many lines that repeat, such as:
ERROR - 2011-07-06 09:19:01 --> 404 Page Not Found --> favicon.ico
Is there any way for me to find out who is calling these errant URLs? The favicon is just an example, there are some URLs that for example show an intent to hack, and others it’s just the same error repeated over and over and over again. Basically I’d love to know which IP’s to potentially block as well as what sites to contact if they have bad links (or if I should just redirect them on my server with .htaccess).
If you feel the need to do this, just extend the Exceptions class and override the
show_404()function:If you keep getting stuff like
favicon.ico, there’s a good chance this is your fault, so you might want to look into that.Just to clarify:
$_SERVER['HTTP_REFERER']will give you the URL the page was requested from, so you can see where the request originated, whether it be on your site or elsewhere.$_SERVER['REMOTE_ADDR']should give you the IP address the request was made byhttp://php.net/manual/en/reserved.variables.server.php
Brief Example: