Add an #_redirect404 id around the custom text. (Setup > Customize Text > Error Messages SubTab > This Category is no longer available.
<td class='medtextbold'><span id="_redirect404">This category is no longer available.</span></td>
And then, place this script within your template:
if(document.getElementById('_redirect404')!=null){
window.location="http://url.com/";
}
Next time, I'll use getElementById futher.