Well, you can of course go through different conditions, and if none is met, return the actual page.
You can also try and check if a route filter might work for your use case.
Otherwise, maybe you want to explain in more details what you want to achieve.