0

How can I force Zend Router to assemble proper urls when the site is running under a directory?

Here's what I mean:

$this->view->url(array('controller' => 'controller', 'action' => 'action'), null, true)

Would usually return something like /controller/action where in my case it returns /tbogdanov/brandenburg/controller/action, because the site is running in the directory /tbogdanov/brandenburg.

That is actually a good URL and I have no problem with it. However, when passed to $this->_redirect() the redirector just prepends the directory again. So, the final redirect url now looks like this: /tbogdanov/brandenburg/tbogdanov/brandenburg/controller/action.

Now, that's incorrect.

Is there any setting I might be missing? It seems zend is aware it is running in a directory/sub-directory, but still at some point, it ignores it. I am looking for a good generalized solution, no str_replace ones!

Also the method should work properly even if at some point the project is moved in the root directory (which will happen).

2 Answers 2

2

The second parameter of _redirect() configures the options. Add array('prependBase' => false) and try again.

Sign up to request clarification or add additional context in comments.

Comments

0

try using a redirector object where you have more options for the link creation

http://framework.zend.com/manual/1.12/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.redirector

    // Redirect to 'my-action' of 'my-controller' in the current
    // module, using the params param1 => test and param2 => test2
    $this->_redirector->gotoSimple('my-action',
                                   'my-controller',
                                   null,
                                   array('param1' => 'test',
                                         'param2' => 'test2'
                                         )
                                   );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.