Phalcon\Http\Response redirect, Phalcon 2 vs Phalcon 1

Hi people,

Sorry to bother you again. I would like to confirm that in Phalcon 2.0.6 if redirecting within the same controller there should be a forward-slash at the beginning of the string. For example:

<?php

class SystemUsersController extends ControllerBase{
// ......
    $this->response->redirect('/systemUsers/action');
    /* instead of 
    $this->response->redirect('systemUsers/action'); // work for Phalcon 1.3, doesn't work for Phalcon 2.0.6
    */

When I was using Phalcon 1.3, it was fine without said forward-slash. But after I upgrade my Phalcon to 2.0.6, if I do not have the forward-slash at the beginning of the redirect string, it'd actually redirect to 'systemUsers/systemUsers/action', which is prepending the controller itself.

Yo, it should be working without:a preceding forward slash:

  //Using a string redirect (internal/external)
$response->redirect("posts/index");
$response->redirect("http://en.wikipedia.org", true);
$response->redirect("http://www.example.com/new-location", true, 301);

//Making a redirection based on a named route
$response->redirect(array(
    "for" => "index-lang",
    "lang" => "jp",
    "controller" => "index"
));

https://docs.phalconphp.com/en/latest/api/Phalcon_Http_Response.html



13.6k

When I have it redirecting to itself, it doesn't work.

Yo, it should be working without:a preceding forward slash:

 //Using a string redirect (internal/external)
$response->redirect("posts/index");
$response->redirect("http://en.wikipedia.org", true);
$response->redirect("http://www.example.com/new-location", true, 301);

//Making a redirection based on a named route
$response->redirect(array(
   "for" => "index-lang",
   "lang" => "jp",
   "controller" => "index"
));

https://docs.phalconphp.com/en/latest/api/Phalcon_Http_Response.html