我有一个Zend Framework项目,以前是其他程序员完成的一半。有了它,另一个应用程序直接桥接到public/hrm
文件夹下的Zend公共文件夹。
该应用程序似乎运行正常。但是在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¤tPage=1
公用文件夹中.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]
我在这里缺少什么?
答案 0 :(得分:4)
您应该修改.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]
这条规则:
RewriteRule ^(hrm)($|/) - [L]
将不会重写任何来自hrm文件夹的内容。
或者在hrm / .htaccess里面放置:
RewriteEngine Off
但我认为,你需要在那里进行一些改写,所以这可能不是选择!
答案 1 :(得分:1)
您可以在application.ini
中添加以下行resources.frontController.baseUrl = "/hrm"