简体   繁体   English

Restler总是在服务器上显示NOT FOUND,但在本地计算机上却不显示

[英]Restler always showing NOT FOUND on server, but not on local machine

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. 目前,我们有2个人从事此项目,并且当我们在本地计算机上运行该项目时,我们俩都没有问题。 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. 代码是相同的,我知道这一点,因为我们使用了git存储库,服务器也从该存储库中提取。

My machine is a mac, my buddy's is a windows machine, and our host is a linux box. 我的机器是Mac,我的伙伴是Windows机器,我们的主机是Linux机器。 This shouldn't really matter, since all of them should work with mod_rewrite, a requirement for Restler 3. 这实际上并不重要,因为它们都应该与mod_rewrite一起使用,这是Restler 3的要求。

The only other details I can think of is that the server is hosted by HostMonster, running PHP 5.4.7 我能想到的唯一其他细节是服务器由运行PHP 5.4.7的HostMonster托管。

Any help would be GREATLY appreciated. 任何帮助将不胜感激。 Do you need more information? 你需要更多的信息?

=== Edit: This is my .htaccess file. ===编辑:这是我的.htaccess文件。 Also, the server runs CGI/FastCGI not mod_php 另外,服务器运行CGI / FastCGI而不是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 我只是用谷歌搜索“ fastcgi mod_rewrite”,但这些链接都没有帮助:P

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 / FastCGI,因此请确保已设置

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 在您的php.ini中,将确保路径信息正确传递给Restler,以便Restler可以找到路线

If it does not work with index.php in the url, you can try generating and verifying routes.php as explained below 如果它不适用于网址中的index.php,则可以尝试生成和验证routes.php ,如下所述

routes.php routes.php

Restler looks at all api methods and its doc comments to generate routes accordingly every time we run it on debug mode. 每当我们在调试模式下运行Restler时,Restler都会查看所有api方法及其文档注释以相应地生成路由。 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. 当我们在生产模式下运行它时,它将捕获routes.php中的信息,并使用它代替每次生成路由,从而提高了效率。

You can check for the generated routes by initializing restler in production mode and refresh on every call 您可以通过在生产模式下初始化Restler来检查生成的路线,并在每次通话时刷新

$r = new Restler(true, true); 

and then check the generated routes.php 然后检查生成的routes.php

If your routes.php contains no routes it will appear as follows 如果您的routes.php包含任何路由,它将显示如下

<?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 如果是这种情况,则意味着自动加载程序无法加载api类,您可以通过手动添加API类来进行确认

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. 如果它开始工作,请使用github问题提出一个错误,指出自动加载器无法为您的服务器配置失败,并提供更多的detils,以便我们可以重现并修复它。

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. 如果仍然无法使用,请使用github问题提出错误,并提及您的服务器配置,并提供任何可能有用的详细信息,以便我们可以重现并修复它。

Thaks to you, we will also write a trouble shooting guide based on above to help the restler community :) 谨在此提醒您,我们还将根据上述内容编写故障排除指南,以帮助Restler社区:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM