We have a lot of side responsibilities at the small NFP I work for. You know when you’re the only person that is good at doing something so you do it even if it’s not technically your job? That kind of thing.

I do a lot of the maintenance and “fiddling” with our WordPress website. I quite like it. Recently I have hit upon an extremely therapeutic activity: managed 404s.

We have a plugin to manage redirections for missing pages. I don’t exactly want to get to zero 404s but I do want to catch and redirect those I can to meaningful places. Even if it is a 410 response.

The really fun part is the plugin supports regular expressions. When I first started working with the plugin my efforts were limited to basic wildcard matches. Now I have even started with optional groups and substitutions. I’m by no means an expert but it is a great learning enviroment.

Today I have come up with a solution I am quite proud of. For some reason, our developer set the versions on our CSS and JS files to randomise occasionally. I assume this is for some sort of caching purposes. Anyway, this can generate some harmless 404s that I don’t want to be logged.

Using the regular expression 101 website I created this solution. Not much point explaining it here as the site does that very well. Any 404 that matches this pattern is excluded from the 404 logs, which helps me spot meaningful 404s much quicker.

Very pleased

Leave a Reply

Your email address will not be published. Required fields are marked *