dan*_*rvt 4 php api rest web-services restler
我被困在这里,在wamp我运行一切并且工作正常,但是,当我尝试在一个centos盒子中安装我的api时,我总是得到一个"Not Found"错误.
我不知道还能做什么!
甚至说/你好的例子都失败了......
是否有任何apache要求的规范来处理restler?
有什么想法吗?有点急
say.php:
<?php
class Say {
function hello($to='world') {
return "Hello $to!";
}
}
Run Code Online (Sandbox Code Playgroud)
的index.php
<?php
require_once 'restler/restler.php';
require_once 'say.php';
$r = new Restler();
$r->addAPIClass('Say');
$r->setSupportedFormats('jsonpformat', 'jsonformat', 'xmlformat', 'yamlformat');
$r->handle();
Run Code Online (Sandbox Code Playgroud)
的.htaccess
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
<IfModule mod_php5.c>
php_flag display_errors On
</IfModule>
Run Code Online (Sandbox Code Playgroud)
错误:
未找到 在此服务器上找不到请求的URL/mylocation/say/hello.
这基本上就是我的所有代码,如果你们认为jsonpformat可能会按照我的方式进行,我可以在这里粘贴代码.
当我输入这样的URL:http://myhost/mylocation/我得到一个json错误:
{
"error": {
"code": 404,
"message": "Not Found"
}
}
Run Code Online (Sandbox Code Playgroud)
如果我输入http://myhost/mylocation/say/hello然后我得到未找到的错误,它就像.htaccess无效.
[编辑]
如果我将"index.php"添加到这样的url中似乎有效:http://myhost/mylocation/index.php/say/hello但是我不能这样离开...
好的,我发现了问题,感谢大家的帮助.
解决方案是AllowOverride将httpd.conf文件的变量设置为All而不是None.一旦我尝试它工作:)
除了apache 的mod_rewrite,我没有找到运行restler的另一个要求,如果我这样做,我会编辑它并把它放在这里.
我发现这是restler的一个常见问题,在文档中提及它可能会很好,希望这可以帮到你.
PD:我必须说在编辑我的问题时投票失败是非常烦人的,因为我发布它后它甚至没有通过一分钟,但是我尽可能快地做了.你可能会说"你为什么发布它呢?" 由于restler需求部分,它不需要太多细节来回答......
| 归档时间: |
|
| 查看次数: |
1253 次 |
| 最近记录: |