4

我被困在这里,在 wamp 中我运行所有东西并且工作正常,但是,当我尝试将我的 api 安装在 centos 盒子中时,我总是收到“未找到”错误。

我不知道还能做什么!

即使是说/你好示例也失败了......

是否有任何关于处理 restler 的 apache 要求规范?

有什么想法吗?,有点急

说.php:

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

索引.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 /mylocation/say/hello。

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

当我像这样输入网址时:http://myhost/mylocation/我收到一个 json 错误:

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

如果我输入http://myhost/mylocation/say/hello然后我得到未找到的错误,它就像 .htaccess 不起作用。

[编辑]

如果我像这样将“index.php”添加到网址中,它似乎可以工作:http://myhost/mylocation/index.php/say/hello但我不能像这样离开它......

我得到了这个:如果 index.php 不包含在 URL 中,Restler 将返回 404 状态代码

4

1 回答 1

6

好的,我找到了问题,谢谢大家的帮助。

解决方案是将文件的AllowOverride变量设置为而不是. 我一尝试它就起作用了:)httpd.confAllNone

除了 apache 的mod_rewrite之外,我没有找到运行 restler 的其他要求,如果我这样做了,我将对其进行编辑并将其放在这里。

我发现这是restler的常见问题,在文档中提及它可能会很好,希望这可以帮助你。

PD:我必须说,在我发布问题后甚至一分钟都没有过时,在编辑我的问题时被否决是非常烦人的,但是我尽可能快地做到了。你可能会说“你为什么要发布它?” 由于restler要求部分,它不需要太多细节来回答......

于 2012-09-08T14:44:13.693 回答