Hooking into page not found event My question is similar to How to redirect user for specific pages not found and some what useful discussion here: https://drupal.org/node/344960 
and redirect missing pages to another site

I've a job site and I want to redirect using 301 all expired jobs to one common page. All expired jobs are deleted. To make it easy the job urls have unix timestamp suffixed in some pattern so that I can recognize a url as expired job.

Whenever a page request comes, I want to let it go normally but if page is not found then only I want to check the url with specific pattern and then redirect 301 to common page if it is url of expired job.

Is there any way to do it?
Go to Home » Administration » Configuration » System and set Error pages to some not used yet value, like http://localhost/403 and http://localhost/404, or http://localhost/forbidden and http://localhost/not-found. Then create a custom module. Implement hook_menu() to provide these pages. Use all logic you need in page callback function.