[英]Zend Framework 404 error issue in new controller
I am very new to ZF and I am working on an already built application. 我是ZF的新手,我正在开发一个已经构建的应用程序。 My task is to create web service in the application. 我的任务是在应用程序中创建Web服务。 I have setup the application locally and its working fine. 我已在本地设置应用程序并且其工作正常。 So I have added a new controller and could access in localhost, but when I tried to access the same in server, it results in 404 error, but other controllers can be accessed perfectly. 所以我添加了一个新的控制器并且可以在localhost中访问,但是当我尝试在服务器中访问它时,它会导致404错误,但是可以完美地访问其他控制器。
AllowOverride All and Apache mod_rewrite is enabled in the server. 在服务器中启用了AllowOverride All和Apache mod_rewrite。 Does anybody have any idea aboout this problem. 有没有人知道这个问题。 I am sitting with this error for 2 days .. 我和这个错误坐了两天..
<VirtualHost *:80>
DocumentRoot /path/to/site/public
ServerName sitename.com
ServerAlias www.sitename.com
<Directory /path/to/site/public>
AllowOverride All
</Directory>
</VirtualHost>
Controller code: 控制器代码:
class APIController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// Setup REST server
$server = new Zend_Rest_Server();
$server->setClass('APIHandlerClass');
$server->handle();
exit;
}
}
I am accessing it with the url site.com/API It will show an XML in actual case. 我正在使用url site.com/API访问它。它将在实际情况下显示XML。
EDIT : 编辑 :
I have setup the application in a local linux system and I found that the problem is related to the linux. 我已经在本地linux系统中设置了应用程序,我发现问题与linux有关。
I have tried the following: 我尝试过以下方法:
Created a new controller which resulted in 404. 创建了一个新的控制器,结果是404。
Copied an existing controller and renamed the orginal controller's name. 复制现有控制器并重命名原始控制器的名称。 Then I have changed the code in copied controller. 然后我更改了复制的控制器中的代码。 I accessed the my controller and it worked! 我访问了我的控制器,它工作了!
Copied an existing controller and renamed the copied controller. 复制现有控制器并重命名复制的控制器。 I called the copied controller with new name, which showed 404 error. 我用新名称调用了复制的控制器,显示404错误。
My question is do I need to specify the new controller name any where!? 我的问题是我需要在哪里指定新的控制器名称!? I didn't find any documentation regarding this and I even created view files for the controller. 我没有找到任何关于此的文档,我甚至为控制器创建了视图文件。
If the application works locally in Windows but doesn't work on the test server running Linux, it's likely to be a case-sensitivity issue. 如果应用程序在Windows中本地运行但在运行Linux的测试服务器上不起作用,则可能是区分大小写的问题。 Check the case of folders, including the controllers folder and the views/scripts folders (both should be lower case). 检查文件夹的大小写,包括controllers文件夹和views / scripts文件夹(两者都应为小写)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.