Apparently you must provide an absolute path to redirect_to
.
Why ? Because redirect_to says ...same arguments as url_for, which generates that url unless it is absolute. The docs aren't too explicit, but the source is.
So you could construct a new Mojo::URL object and give it to redirect_to
:
my $url = Mojo::URL->new->base($self->req->url->base->clone)->base->userinfo(undef);
$url = $url->path('/anothersubdir/some.html');
$self->redirect_to( $url );
Or copy redirect_to
and modify it to not use url_for
sub redirect_raw {
my $self = shift;
# Don't override 3xx status
my $res = $self->res;
#~ $res->headers->location($self->url_for(@_)->to_abs);
$res->headers->location();
return $self->rendered($res->is_status_class(300) ? () : 302);
}