user1429980
user1429980

Reputation: 7158

Restler 3: 404 on all routes

I am trying to use Restler in a PHP app api, but I am getting a 404 object returned on all requests. I have reviewed the following similar questions:

I am almost certain that the problem lies in the server configuration. I can run the example files in my local environment, but as soon as I push it to the live server, this problem persists.

For example, when I copy the folder _001_helloworld, which works locally, to my server, I get 404 response body:

{
error: {
code: 404,
message: "Not Found"
},
debug: {
source: "Routes.php:431 at route stage",
stages: {
success: [
"get"
],
failure: [
"route",
"negotiate",
"message"
]
}
}
}

Here is my PHPInfo

How can I fix all routes returning 404 in the response body in Restler.

Upvotes: 0

Views: 1125

Answers (1)

John K
John K

Reputation: 11

Ik spent an entire day solving this exact same problem but finally managed to do so. On localhost everything was running smoothly but on the server I got the same 404 error ("Routes.php:431 at route stage") as you did.

This is what solved it for me:

I had to move the .htaccess to the root of the website and then changed the RewriteRule to have [location of your api]/index.php instead of just index.php.

My .htaccess file:

Options -MultiViews
DirectoryIndex api/helloworld/index.php
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^$ api/helloworld/index.php [QSA,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ api/helloworld/index.php [QSA,L]
</IfModule>
<IfModule mod_php5.c>
    php_flag display_errors Off
</IfModule>

Basic hello world example can now be called like this: GET [servername]/say/hello

Upvotes: 1

Related Questions