[FLOW3-general] Redirect seems to ignore routing

Torben Hansen derhansen at gmail.com
Sun Nov 18 12:23:50 CET 2012


Hello,

I have a question about TYPO3 Flow’s routing used together with the
redirect() method from the abstractController. It seems, that the
redirect() method ignores the routing setup.

I have a simple project, where I created a controller named “Login” with an
action named “Index”. I can open the URL for the action like this:

http://site.local/my.package/login/index

Now I create a routing entry for this action, so I can get rid of the
package name in the URL. My routing setup looks like this.

-
  name: 'Login'
  uriPattern: 'login'
  defaults:
    '@package': 'My.Package'
    '@controller': 'Login'
    '@action': 'index'

Using this routing setup, I get an URL like this:

http://site.local/login

Nice, that was exactly what I wanted. Now I have another controller, where
I just redirect to the Login-Controller I created. The redirect looks like
this.

$this->redirect('index', 'Login', 'My.Package', array('some' => ‘param’))

But the redirect seems to ignore the routing (or a part of it), since it
Redirects to:

http://site.local/my.controller/login?some=params

Now the package name is included in the URL again.

Using the uriBuiler to create the redirection works fine.

$uri = $this->uriBuilder->setCreateAbsoluteUri(TRUE)->uriFor('index',
array('some' => ‘param’), 'Login', 'My.Package');
$this->redirectToUri($uri);

This results the controller to redirect to:

http://site.local/login?some=params

Am I missing some configuration setup in the routing or is this a bug or
feature?

I found out, that the redirect() method from the abstractController also
uses the uriBuilder to do the redirection. The only difference is, that it
adds a format to uriBuilder with the setFormat() method, which causes the
package name to be included in the resulting URL.

What is the "format" used for and why does the resulting URL include the
package name, when I configured the routing to exclude the package name?

Can anyone help me with this?

Best regards
Torben


More information about the FLOW3-general mailing list