views:

38

answers:

2

i notice that when i run a zend framework app from a server, there are alot of side effects. main issue is where i use urls like

/auth/login

i need to use

$this->baseUrl('/auth/login');

thats simple to fix. but when i use

$request->getRequestUri()

for use in redirects. eg after login, i want to redirect the user back to the prev page, it goes to the wrong place. eg. my app root is "http://localhost/app1", $request->getRequestUri() will give /app1. when i try to redirect back, it will goto http://localhost/app1/app1. btw, i am using Zend Server + IIS7 and my app is configured to run from the url stated above. maybe i shld be going to "/" instead. how can i resolve this?

update

this is in my Zend_Form class

// (Zend_Form) Login.php init()
$req = Zend_Controller_Front::getInstance()->getRequest();
$returnUrl = $req->getParam('returnUrl', $req->getRequestUri());
$this->addElement('hidden', 'returnUrl', array(
    'value' => $returnUrl
));

// AuthController after login
$returnUrl = urldecode($form->getElement('returnUrl')->getValue());
if (!empty($returnUrl)) {
    $this->_helper->getHelper('Redirector')->setGotoUrl($returnUrl);
}
A: 

I have solved this problem with help of Apache configs. In file \usr\local\apache\conf\vhosts.conf find a block with your site and change ways and public folder.

Alexander.Plutov
i am using iis now, i used apache b4 tho. i am trying out ZS with IIS, heard its faster
jiewmeng
+2  A: 

Based on you update:
Its the prependBase-Option in the Redirector what you are looking for:

prependBase: boolean flag indicating whether or not to prepend the base URL when a relative URL is provided

So your fix is:

$this->_helper->getHelper('Redirector')->setGotoUrl($returnUrl, array('prependBase' => false));
Benjamin Cremer
works like a charm. tho i am curious any reason to use `prependBase = true`?
jiewmeng