C_Fun - If by all those non-functional pages you mean all 404s, that should be easy - just look for the page not found template in studio and remove the search component from there. The name of that page is Error404Page. Also, the search component must be in your common header - so, just put the if condition to exclude it from Error404Page and it won't render there.