Restler总是返回未找到的结果


Restler always returns not found

我被困在这里,在wamp中,我运行所有东西,工作正常,然而,当我试图在centos盒子中安装我的api时,我总是收到"未找到"错误。

我不知道还能做什么!

即使是say/hello示例也失败了。。。

有没有关于处理restler的apache需求的规范?

有什么想法吗?,这是一种紧急的

say.hp:

<?php
class Say {
    function hello($to='world') {
        return "Hello $to!";
    }
}

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();

.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>

错误:

未找到在此服务器上找不到请求的URL/mlocation/say/hello。

这基本上就是我所有的代码,如果你们认为jsonpformat可能会妨碍我,我可以把代码粘贴到这里。

当我键入这样的url:http://myhost/mylocation/时,我得到一个json错误:

{
  "error": {
    "code": 404,
    "message": "Not Found"
  }
}

如果我键入http://myhost/mylocation/say/hello,则会出现未找到错误,类似于.htaccess不起作用。

[EDIT]

如果我像这样把"index.php"添加到url中:http://myhost/mylocation/index.php/say/hello,这似乎是可行的,但我不能这样。。。

我从中得到:如果index.php没有包含在URL 中,Restler将返回404状态代码

好的,我发现了问题,感谢大家的帮助。

解决方案是将httpd.conf文件的AllowOverride变量设置为All而不是None。我一试就奏效了:)

除了apache的mod_rewrite之外,我没有发现运行restler的其他要求,如果我发现了,我会编辑它并将其放在这里。

我发现这是restler的常见问题,最好在文档中提及,希望这能对您有所帮助。

PD:我必须说,在编辑我的问题时被投票否决是非常令人讨厌的,因为我发布问题还不到一分钟,但我尽可能快地完成了。你可能会说"你当时为什么发布它?"因为restler需求部分,它不需要太多细节来回答。。。