MediaWiki 404 Errors
By Phil on Tuesday, April 6 2010, 10:16 - Computing - Permalink
Whenever a wiki page that doesn't exist is accessed in MediaWiki, it logs a 404 error in the Apache logs. This quickly adds up to a lot of false-positives on 404 reports for something that is normal operation for MediaWiki.
MediaWiki is doing the correct thing here -- if the page doesn't exist, then 404 should be the HTTP status code. But at the same time, as a system admin, I don't care about these particular 404 errors, so I don't want to be bothered by them in my logs.
Solution: Using mod_rewrite and mod_setenvif we can create rules to avoid logging these errors:
RewriteEngine on RewriteCond %{REQUEST_URI} ^/index\.php/(.+) RewriteCond %{REQUEST_URI} -U RewriteRule ^(.*)$ - [env=dontlog:true] CustomLog "/var/log/httpd/wiki-access_log" combined env=!dontlog
This assumes your wiki is in the top-level of a subdomain. If your wiki is actually hosted in a sub-directory such as www.mydomain.com/content/wiki then modify the RewriteCond to suit:
RewriteEngine on RewriteCond %{REQUEST_URI} ^/content/wiki/index\.php/(.+) RewriteCond %{REQUEST_URI} -U RewriteRule ^(.*)$ - [env=dontlog:true] CustomLog "/var/log/httpd/wiki-access_log" combined env=!dontlog