简体   繁体   English

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

[英]“Invalid controller specified” error in zend framework 1

I have a Zend Framework project previously half done by other programmers.我有一个 Zend Framework 项目,之前一半是由其他程序员完成的。 With it another application is directly bridged into Zend's public folder under public/hrm folder.有了它,另一个应用程序被直接桥接到 Zend 的public/hrm文件夹下的公共文件夹中。

The application seems to run okay.该应用程序似乎运行正常。 But at the apache error log I constantly find these errors.但是在 apache 错误日志中,我不断发现这些错误。

  [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\n
  Stack trace:
  \n#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))
  \n#1 /path/to/proj/Application/Bootstrap.php(48): Zend_Controller_Front->dispatch()
  \n#2 /path/to/proj/public/index.php(30): Application_Bootstrap->run()
  \n#3 {main}
  \n  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\nStack trace:
  \n#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))
  \n#1 /path/to/proj/Application/Bootstrap.php(48): Zend_Controller_Front->dispatch()
  \n#2 /path/to/proj/public/index.php(30): Application_Bootstrap->run()
  \n#3 {main}
  \n  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: public文件夹下.htaccess的内容如下:

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 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.你应该修改你的 .htaccess,我认为有人试图访问一些不存在的 hrm 文件夹中的文件,在这种情况下,请求被转发到你的应用程序,它试图找到 hrm 模块或控制器,因为它是不在那里,它会引发错误。

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.将使它不会从 hrm 文件夹中重写任何内容。

Or inside hrm/.htaccess put:或者在 hrm/.htaccess 里面放:

RewriteEngine Off

But i assume, you need some rewriting there so this might not be the option!但我认为,您需要在那里进行一些重写,所以这可能不是选择!

您可以在 application.ini 中添加以下行

resources.frontController.baseUrl = "/hrm" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM