Hi, of course you can use the redirect-function just with a url based on the input. This is basically what you provide PW with $protein_page->url.
But I'm not quite sure if this makes a big difference in your case since you're using $pages->get before. So just try out what works better / more performant for you.