Restler always returns not found

廉价感情. 提交于 2019-12-01 05:29:21

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/12323908/restler-always-returns-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!