Reputation: 564
When I go to
http://localhost/api/auth/login
I get what I expect.. some data that lets me log in.
However, when I go to
http://myurl.com/api/auth/login
I just get
{
"error": {
"code": 404,
"message": "Not Found"
}
}
Currently we have 2 people working on this project, and both of us, when we run it from our local machines, have no issues. We're to the point where we are putting the app on to a hosted server so that we can start testing it outside of our own machines.
The code is identical, and I know this because we use a git repository in which the server is also pulling from.
My machine is a mac, my buddy's is a windows machine, and our host is a linux box. This shouldn't really matter, since all of them should work with mod_rewrite, a requirement for Restler 3.
The only other details I can think of is that the server is hosted by HostMonster, running PHP 5.4.7
Any help would be GREATLY appreciated. Do you need more information?
=== Edit: This is my .htaccess file. Also, the server runs CGI/FastCGI not mod_php
Options -MultiViews
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 Off
</IfModule>
I just googled 'fastcgi mod_rewrite' and none of those links helped :P
Upvotes: 0
Views: 1074
Reputation: 993
When ever you come across such issue first try without url rewriting
instead of
http://myurl.com/api/auth/login
try
http://myurl.com/api/index.php/auth/login
If it works you will know that the issue is with url rewriting
Since you are using CGI/FastCGI make sure you have set
cgi.fix_pathinfo=0
in your php.ini it will make sure that path info is passed to Restler properly so that restler can find the route
If it does not work with index.php in the url, you can try generating and verifying routes.php
as explained below
Restler looks at all api methods and its doc comments to generate routes accordingly every time we run it on debug mode. When we run it on production mode it captures the information in routes.php and uses it instead of generating routes every time thus improving efficiency.
You can check for the generated routes by initializing restler in production mode and refresh on every call
$r = new Restler(true, true);
and then check the generated routes.php
If your routes.php
contains no routes it will appear as follows
<?php $o = array();
// ** THIS IS AN AUTO GENERATED FILE. DO NOT EDIT MANUALLY **
return $o;
If this is your case, it means some how autoloader is failing to load the api class, you can confirm it by manually including the API classes
If it starts to work, please file a bug using github issues stating that the autoloader is failing for your server configuration and give us more detils so that we can reproduce it and fix it.
If it still does not work, please file a bug using github issues mentioning your server configuration and give us any detail that could help so that we can reproduce it and fix it.
Thaks to you, we will also write a trouble shooting guide based on above to help the restler community :)
Upvotes: 2