Zend certified PHP/Magento developer

Do a 301 redirect if there is no products in the current category

As a part of the SEO optimizations, when a customer go to a category page and if there is no products in the category, can we redirect it to a 301?

Eg: As a part of -ve testing, if we load the category page with a non valid page number, then magento will show the message as “We can’t find products matching the selection.”. So instead of this i want to either redirect to 301 OR redirect 404 is also fine in this case. Do we have any solution for this?