0

i am using zend framework 1.12.3.

index.php :

    switch(strtolower($_SERVER['REQUEST_URI'])) {
      case '/admin/':  
        define('APPLICATION_PATH',
        realpath(dirname(__FILE__) . '/../application/admin'));
      break;
      case '/store/':  
        define('APPLICATION_PATH',
        realpath(dirname(__FILE__) . '/../application/stoe'));
      break;
      default:  
        define('APPLICATION_PATH',
        realpath(dirname(__FILE__) . '/../application/store'));
      break;
    }

Admin controller :

    public function init()
    {
        /* Initialize action controller here */

    }

    public function indexAction()
    {
      $request = $this->getRequest();  

      $this->view->assign('title', 'Login Form');
      $this->view->assign('username', 'User Name'); 
      $this->view->assign('password', 'Password');
    }


    public function authAction()
    {
       echo 'test';exit;    
    }

when i access the url: http://pro.localhost/admin/ - this is working

but when i access the url : http://pro.localhost/admin/auth showing error 'Page not found' and 'Message: Invalid controller specified (admin) '

2
  • show your .htaccess file Commented Jan 21, 2014 at 11:46
  • Have you got a related view file auth.phtml in place for the AuthAction? Commented Jan 21, 2014 at 11:49

1 Answer 1

1

$_SERVER['REQUEST_URI'] isn't equal to '/admin/' when you visit '/admin/auth/', so APPLICATION_PATH is being defined as the store path instead. You should be checking for whether $_SERVER['REQUEST_URI'] begins with '/admin/'. And you shouldn't need a switch statement to check two conditions.

if (strpos(strtolower($_SERVER['REQUEST_URI']), '/admin/') === 0) {
    define(
        'APPLICATION_PATH',
        realpath(dirname(__FILE__) . '/../application/admin')
    );
} else {
    define(
        'APPLICATION_PATH',
         realpath(dirname(__FILE__) . '/../application/store')
    );
}
Sign up to request clarification or add additional context in comments.

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.