【问题标题】:CodeIgniter RESTful works offline but not onlineCodeIgniter RESTful 离线工作但不能在线
【发布时间】:2014-12-29 18:03:54
【问题描述】:

我相信我有这个问题的原因是因为.htaccess(尽管它们在离线和在线时是一样的)。

http://localhost/myProject/api/webservice/getUsers -> Works
http://myProjectDomain.com/api/webservice/getUsers -> Doesn't work, error: 500 Internal Error

.htaccess 从根文件夹:

Options -Indexes
Options +FollowSymLinks

# Set the default file for indexes
DirectoryIndex index.php

<IfModule mod_rewrite.c>

    # activate URL rewriting
    RewriteEngine on

    # do not rewrite links to the documentation, assets and public files
    RewriteCond $1 !^(index\.php|public|images|robots\.txt)

    # do not rewrite for php files in the document root, robots.txt or the maintenance page
    RewriteCond $1 !^([^\..]+\.php|robots\.txt)

    # but rewrite everything else
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>

    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.

    ErrorDocument 404 index.php

</IfModule> 

在我看来,我可能需要创建另一个规则?比如:

RewriteRule ^(.*)$ index.php?/api/webservice/$1 [L]

【问题讨论】:

    标签: php apache .htaccess codeigniter rest


    【解决方案1】:

    已解决。

    我在这个话题中找到了我的答案:malformed header from script. Bad header=1: index.php

    几周前,我不得不更改我的REST_controller.php 文件,以便从网络服务接收大量数据。虽然我发现了一个小bug,但是当数据量太大时,它不会完全检索到它。

    例如 JSON 格式。

    [{data: {'values': '1'}, {'values': '2'}]
    

    现在这是大规模只检索我:

    [{data: {'values': '1'}, {'values': '2'
    

    是的,它错过了}],因此 JSON 格式不好。 所以我改变了一点代码,来自:

    header('Content-Length: ' . strlen($output));
    

    到:

    header('Content-Length: ' . strlen($output) + 15);
    

    但是我犯了一个基本错误,如果我使用类型化语言进行编码,我就不会犯这种错误。 这些值实际上并没有相加,而是连接在一起。解决方案:

    header('Content-Length: ' . (strlen($output) + 15));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-07-16
      • 1970-01-01
      • 2012-01-14
      • 2013-10-18
      • 1970-01-01
      • 1970-01-01
      • 2015-02-14
      相关资源
      最近更新 更多