使用slimphpv3.x重定向
我的slimphp应用程序中有一条路由。例如:gallery.dev/roomPicture/RoomDetails/212。我想将所有这些请求重定向到route gallery.dev/login。以下是我尝试过的:使用slimphpv3.x重定向,php,redirect,slim,Php,Redirect,Slim,我的slimphp应用程序中有一条路由。例如:gallery.dev/roomPicture/RoomDetails/212。我想将所有这些请求重定向到route gallery.dev/login。以下是我尝试过的: $app->get('/roomPicture/RoomDetails/{id}', function (Request $request, Response $response, $args){ //some code return $this->respons
$app->get('/roomPicture/RoomDetails/{id}', function (Request $request, Response $response, $args){
//some code
return $this->response->withStatus(200)->withHeader('Location', 'login');
这会多次将我重定向到gallery.dev/roomPicture/RoomDetails/login,然后抛出一个错误
你知道我该怎么解决吗
谢谢 重定向状态代码为301。同时将url更改为绝对
/login
。现在它是相对于当前路径的,所以login
在当前路径目录前面
return $this->response->withStatus(301)->withHeader('Location', '/login');
或者使用重定向($url,$status=null)对其使用特殊方法
重定向状态代码为301。同时将url更改为绝对/login
。现在它是相对于当前路径的,所以login
在当前路径目录前面
return $this->response->withStatus(301)->withHeader('Location', '/login');
或者使用重定向($url,$status=null)对其使用特殊方法