slimphp / Slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
http://slimframework.com
MIT License
11.96k stars 1.95k forks source link

Slim 3 Php-View #2617

Closed ghost closed 5 years ago

ghost commented 5 years ago

I've use slim for make only url rewrite and friendly url's, it's a good framework, love it!!! But need make redirect for a page after user make login! i've using php-view! In pure php: header("Location: views/dashboard.php"), but on slim, how make this? Trying: return $response = new Slim\Http\Response::withRedirect('Location', $router->pathFor('dashboard')) but don't works! and I don't use MVC!!!

tflight commented 5 years ago

The withRedirect method takes two arguments, the URL and then the status code. See the Returning a Redirect documentation for more info. So it would look more like this:

withRedirect($router->pathFor('dashboard'), 301);
ghost commented 5 years ago

Ok! Thanks!!