Restler总是返回找不到 [英] Restler always returns not found

查看:36
本文介绍了Restler总是返回找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被困在这里,在 wamp 中我运行了一切并且工作正常,但是,当我尝试在 centos 框中安装我的 api 时,我总是收到未找到"错误.

我不知道还能做什么!

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

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

有什么想法吗,有点急

say.php:

index.php

addAPIClass('Say');$r->setSupportedFormats('jsonpformat', 'jsonformat', 'xmlformat', 'yamlformat');$r->handle();

.htaccess

DirectoryIndex index.php<IfModule mod_rewrite.c>重写引擎开启重写规则 ^$ index.php [QSA,L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d重写规则 ^(.*)$ index.php [QSA,L]</IfModule><IfModule mod_php5.c>php_flag display_errors 开启</IfModule>

错误:

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

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

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

<代码>{错误": {代码":404,未找到信息"}}

如果我输入 http://myhost/mylocation/say/hello 然后我会收到 not found 错误,就像 .htaccess 不工作.

如果我像这样在 url 中添加index.php"似乎可以工作:http://myhost/mylocation/index.php/say/hello,但我不能离开像这样...

我来自:如果 URL 中不包含 index.php,Restler 返回 404 状态码

解决方案

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

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

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

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

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

I'm stuck here, in wamp I run everything and works fine, however, when I tried to install my api in a centos box, I always get a "Not Found" error.

I dont know what else to do!

Even the say/hello example fails...

Is there any specification of the apache requirements to handle restler?

Any ideas?, it is kind of urgent

say.php:

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

error:

Not Found The requested URL /mylocation/say/hello was not found on this server.

Thats basically all my code, if you guys think that jsonpformat might be steping in my way I could paste that code here.

When I type the url like this: http://myhost/mylocation/ I get a json error:

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

If I type http://myhost/mylocation/say/hello then I get the not found error, its like .htaccess isn't working.

[EDIT]

It seems to work if I add "index.php" to the url like this: http://myhost/mylocation/index.php/say/hello, but I can't leave it like this...

I got this from: Restler returns 404 status code if index.php is not included in URL

解决方案

Ok, I found the problem, thanks everyone for your help.

The solution was to set the AllowOverride variable of the httpd.conf file to All instead of None. As soon as I tried that it worked :)

Besides the mod_rewrite of apache, I didn't find another requirement to run restler, if I do, I'll edit this and put it here.

I found that this is a common issue with restler and it might be good to mention it in the documentation, hope this can help you.

PD: I must say that is very annoying to be voted down while editing my question when it didn't even passed a minute since I posted it, however I did as fast as I could. You might say "why did yout posted it then?" Because of the restler requirements part, it doesn't require much detail to answer that...

这篇关于Restler总是返回找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆