Tunning (tuning) WordPress

Tweaking the wordpress 404 template such that error pages for images and other linked items do not go the full blown 404 error page.

Today on the server logs I found about 2900 404 errors triggered from a single IP, the logs are similar as


[IP REMOVED] keralaonline.com - [27/Apr/2009:11:38:34 +0530] "GET /wp-content/uploads/2009/04/photo993.jpg HTTP/1.0" 404 18013 "https://keralaonline.com/wp-content/uploads/2009/04/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
[IP REMOVED] keralaonline.com - [27/Apr/2009:11:38:38 +0530] "GET /wp-content/uploads/2009/04/photo997.jpg HTTP/1.0" 404 18013 "https://keralaonline.com/wp-content/uploads/2009/04/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
[IP REMOVED] keralaonline.com - [27/Apr/2009:11:38:39 +0530] "GET /wp-content/uploads/2009/04/photo999.jpg HTTP/1.0" 404 18013 "https://keralaonline.com/wp-content/uploads/2009/04/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"

one can see that the request is scripted and at a random interval, seems to be a script kiddie trying to leech images, but I got worried that even for this wordpress would go and output my pretty 404 page, which was as you could see is a whopping 17Kb, and takes about half a second to build. So just gave a twist and modified the top area of my 404 template to


<?php
if(eregi('/wp-content',$_SERVER['REQUEST_URI'])){
  echo 
'<h1>Not found</h1>';
  exit();
}else
  
get_header(); ?>

which changed the traffic down to 18 bytes per 404 error, as in


[IP REMOVED] keralaonline.com - [27/Apr/2009:22:15:10 +0530] "GET /wp-content/themes/Kol/jiju.jpg HTTP/1.1" 404 18 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/2008121621 Ubuntu/8.04 (hardy) Firefox/3.0.5; https://www.jijutm.com"