Hi there,
Sorry for my english,i just point out the bug with codes.
bootstrap file code:
// index.php
$router = new Zend_Controller_RewriteRouter();
$router->addRoute('passport',new
Zend_Controller_Router_Route(':action',array('controller'=>'passport','action'=>'login')));
$front = Zend_Controller_Front::getInstance();
$front->setRouter($router);
$front->setControllerDirectory(CONTROLLER_DIR);
$front->throwException(true);
try {
$front->dispatch();
} catch(Zend_Exception $e) {
Zend::dump($e);
}
passport controller code:
// PassportController.php
class PassportController extends Zend_Controller_Action
{
public function loginAction()
{
echo 'login action<br/>';
echo $this->getRequest()->getParam('forward');
}
public function registerAction()
{
echo 'register action<br/>';
echo $this->getRequest()->getParam('forward');
}
public function logoutAction()
{
echo 'logout action<br/>';
echo $this->getRequest()->getParam('forward');
}
}
type following url to test the route result:
test group one:
http://myhost/login // output 'login action<br/>' ,call login
succ
http://myhost/register // output 'register action<br/>',call
register succ
http://myhost/logout // output 'logout action<br/>' , call logout
succ
test group two:
http://myhost/login?forward=index.php // output 'login
action<br/>index.php',actually
call login failed
http://myhost/register?forward=index.php // output 'login action<br/>
index.php',call register failed
http://myhost/logout?forward=index.php // output 'login action<br/>
index.php',call logout failed
test group three:
http://myhost/login?forward=test.php // output 'login action<br/>test.php'
,call login succ
http://myhost/register?forward=test.php // output 'register action<br/>
test.php' ,call login succ
http://myhost/logout?forward=test.php // output 'logout action<br/>test.php'
,call login succ
....
you can pass other string to the forward query string to test it,if the
query string is end up with index.php,it may be call non-default action
failed.
Regards
Jacky