How to redirect to a 404 error from a plugin

Hi everyone, I’m trying to redirect to a 404 page from a plugin with this method

but nothing is happening… If you have a solution!

Thank you! Thank you!

you need to declare your function in getSubscribedEvents() function


public function onPageNotFound(Event $event)
// do your stuff


you can check many plugins use that method
… welcome to Grav Community :grinning: