How to redirect with status 301?

Hello team, i was trying to make a simple redirect with status 301, but it’s keep setting 302 on header.

return $response->withStatus(301)->withRedirect("/newurl");

Regards

withRedirect() takes the status as the second parameter:

return $response->withRedirect('/newurl', 301);

or

return $response->withRedirect('/newurl')->withStatus(301);
2 Likes

Fixed with https://github.com/slimphp/Slim/pull/1859

1 Like