Questions tagged «slim»

8
在.htaccess中启用cors
我已经使用SLIM PHP框架创建了一个基本的RESTful服务,现在我试图将其连接起来,以便可以从Angular.js项目访问该服务。我已经知道Angular开箱即用地支持CORS,而我要做的就是Header set Access-Control-Allow-Origin "*"在我的.htaccess文件中添加以下行: 我已经做到了,我的REST应用程序仍然可以正常工作(.htaccess错误导致500个内部服务器没有错误),但是当我尝试从test-cors.org对其进行测试时,它抛出了错误。 Fired XHR event: loadstart Fired XHR event: readystatechange Fired XHR event: error XHR status: 0 XHR status text: Fired XHR event: loadend 我的.htaccess文件如下所示 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ /index.php [QSA,L] Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT" 我还需要添加其他东西到.htaccess中才能使其正常工作,还是有另一种方法可以在服务器上启用CORS?
71 php  apache  .htaccess  cors  slim 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.