If you run an Apache2 server then you have no doubt seen the following error messages a thousand times in your error.log file:
File does not exist: /var/www/robots.txt
File does not exist: /var/www/favicon.ico
As you know by now not having a favicon.ico file web browsers will requesting it each time. But you can tell Apache2 not to log the event as a mistake message.
You will still see the request in the access.log, but at least you will have a cleaner error.log file.
Solution:
Add the following block of code to each VirtualHost :
Redirect 404 /favicon.ico <Location /favicon.ico> ErrorDocument 404 "No favicon" </Location>Redirect 404 /robots.txt <Location /robots.txt> ErrorDocument 404 "No robots.txt" </Location>
Now restart the Apache2 server:
/etc/init.d/apache2 restart
Restarting web server: apache2 … waiting .
If you an Nginx server you’ll need to create a file called drop in the /conf folder, including this into your server configuration will drop/block
common files you do not wish to be exposed to the web:
The file should be like this:
# Most sites won’t have configured favicon or robots.txt
# and since its always grabbed, turn it off in access log
# and turn off it’s not-found error in the error log
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
Enjoy.

Download as PDF
Recent Comments