PHP 301 redirect with message?

I have a problem my website is a forum I removed about 300 threads and now Google is returning lots of 404 errors so I need a way to redirect all that traffic to homepage. I need 301 redirect but with a message?

<snip />

Instead of a 301 Redirects, why don’t you make a 404 error page that has a message, search bar, and or site map that will help visitors find what they are looking for. If you really must use a 301 Redirect, you could add a query string to the link. IE: http://myhomepage?message=1

Then display the message if(message==1). This could be done on the front end with JavaScript or back-end with PHP or whatever you are using.