How to Hide Some Dynamic Item Pages using code

Hi, though this worked, as it redirects after the load, it reveals the page for a moment too long. So I’ve tried to do this using routers instead. Could you suggest a solution; my post showing latest attempts- How to Redirect some Dynamic Item pages using Routers