Redirect to 404

Hi!

Im letting users visit other users profiles with www.example.com/@username.

And i check if that user exist and show that user data.

If it doesn’t exist, i redirect with return $response->withStatus(404)->withHeader('Content-Type', 'text/html')->write('Page not found');. But i would like to show the “original” 404 page, or the 404 page in notFoundHandler. Is there a redirect->404() or something similar?

You can invoke the NotFound handler

Thanks for your reply!

But how do i do that?

http://www.slimframework.com/docs/handlers/not-found.html

Yes i have read that.

But i don’t know how i can invoke this…

i want to return 404

If you want to use the default 404 implementation your can just get it from the container.

$notFoundHandler = $this->container->get('notFoundHandler');
return $notFoundHandler($request, $response);