Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 允许Zend 1.11.6中的HTTP选项方法_Php_Apache_Zend Framework_Cors - Fatal编程技术网

Php 允许Zend 1.11.6中的HTTP选项方法

Php 允许Zend 1.11.6中的HTTP选项方法,php,apache,zend-framework,cors,Php,Apache,Zend Framework,Cors,我试图在Zend 1.11.6中完成的一个旧项目上启用跨源资源共享CORS,问题似乎是初始飞行测试选项请求中抛出的异常。以下是对HTTP选项请求的完整响应: 标题: 正文: 我在library/Zend/Controller/Action.php中找到了Zend_Controller_Action的错误消息。我的问题是:修改框架以允许此请求的适当位置在哪里?我可以在一个控制器一个控制器的基础上或在整个项目范围内这样做 此外,我还通过.htaccess启用了CORS,我已将其粘贴到下面: Head

我试图在Zend 1.11.6中完成的一个旧项目上启用跨源资源共享CORS,问题似乎是初始飞行测试选项请求中抛出的异常。以下是对HTTP选项请求的完整响应:

标题:

正文:

我在library/Zend/Controller/Action.php中找到了Zend_Controller_Action的错误消息。我的问题是:修改框架以允许此请求的适当位置在哪里?我可以在一个控制器一个控制器的基础上或在整个项目范围内这样做

此外,我还通过.htaccess启用了CORS,我已将其粘贴到下面:

Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin"
Header add Access-Control-Allow-Headers "x-requested-with"
Header add Access-Control-Allow-Headers "content-type"
Header add Access-Control-Allow-Methods "PUT"
Header add Access-Control-Allow-Methods "GET"
Header add Access-Control-Allow-Methods "POST"
Header add Access-Control-Allow-Methods "DELETE"
Header add Access-Control-Allow-Methods "OPTIONS"

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
以下是我的“验证控制器选项”操作:

public function optionsAction()
{
    $this->view->data = Array();
    $this->view->success = true;
}

查看Zend_Rest_Route::match,您需要将其设定/扩展为将选项方法映射到控制器中的选项操作。

能否显示控制器的代码?尤其是在选项操作方面,这种方法似乎缺失了。我没有选项操作。我刚加了一个,我会更新帖子的。这并没有改变人们的反应。
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin"
Header add Access-Control-Allow-Headers "x-requested-with"
Header add Access-Control-Allow-Headers "content-type"
Header add Access-Control-Allow-Methods "PUT"
Header add Access-Control-Allow-Methods "GET"
Header add Access-Control-Allow-Methods "POST"
Header add Access-Control-Allow-Methods "DELETE"
Header add Access-Control-Allow-Methods "OPTIONS"

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
public function optionsAction()
{
    $this->view->data = Array();
    $this->view->success = true;
}