开发者

Zend Framework: From a folder (not /)

开发者 https://www.devze.com 2023-01-11 12:09 出处:网络
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

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.开发者_StackOverflow社区 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);
}


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));


If you are using Zend_Application you can use this in your application.ini, and wont need to specify anything else.

resources.frontController.baseUrl = "/your/public/path/"


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消