zend框架1中的“指定的控制器无效”错误

I have a Zend Framework project previously half done by other programmers. With it another application is directly bridged into Zend's public folder under public/hrm folder.

The application seems to run okay. But at the apache error log I constantly find these errors.

  [Wed Dec 25 12:33:00 2013] [error] [client 127.0.0.1] 
  PHP Fatal error:  Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (hrm)' in /path/to/proj/library/Zend/Controller/Dispatcher/Standard.php:248

  Stack trace:
  
#0 /path/to/proj/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
  
#1 /path/to/proj/Application/Bootstrap.php(48): Zend_Controller_Front->dispatch()
  
#2 /path/to/proj/public/index.php(30): Application_Bootstrap->run()
  
#3 {main}
  
  thrown in /path/to/proj/library/Zend/Controller/Dispatcher/Standard.php on line 248, referer: http://local.hrm.tld/hrm/lib/controllers/CentralController.php?reqcode=EMP&VIEW=MAIN&sortField=0&sortOrder0=ASC&VIEW=MAIN

  [Wed Dec 25 12:33:04 2013] [error] [client 127.0.0.1] 
  PHP Fatal error:  Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (hrm)' in /path/to/proj/library/Zend/Controller/Dispatcher/Standard.php:248
Stack trace:
  
#0 /path/to/proj/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
  
#1 /path/to/proj/Application/Bootstrap.php(48): Zend_Controller_Front->dispatch()
  
#2 /path/to/proj/public/index.php(30): Application_Bootstrap->run()
  
#3 {main}
  
  thrown in /path/to/proj/library/Zend/Controller/Dispatcher/Standard.php on line 248, referer: http://local.hrm.tld/hrm/lib/controllers/CentralController.php?menu_no_top=hr&id=0008&capturemode=updatemode&reqcode=EMP&currentPage=1

the content of .htaccess at public folder is as follows:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

What am I missing here?

You can add following line into your application.ini

resources.frontController.baseUrl = "/hrm" 

You should modify your .htaccess, i think someone is trying to access some files in hrm folder that don't exist, in this case, the request gets forwarded to your application, which tries to find the hrm module or controller, since it is not there, it throws an error.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(hrm)($|/) - [L]
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

This rule:

RewriteRule ^(hrm)($|/) - [L]

Will make it not rewrite anything from hrm folder.

Or inside hrm/.htaccess put:

RewriteEngine Off

But i assume, you need some rewriting there so this might not be the option!