CakePHP 控制器,Url 在服务器上找不到

CakePHP controller , Url not found on server

我在 CakePhp-2.9 中写了一个名为 API 的控制器来访问外部。 控制器代码:

class APIController extends AppController
{
var $name = 'API';
var $cache_dir = 'img/cache';
var $cache_width = 400;
public $msgs = array();

public function beforeFilter()
{
    parent::beforeFilter();
         $this->Auth->allow('ecall_request','ecall_callback','testlog','ecall_request_test','ecall_callback_test');

} 


public function ecall_request()
{   


Cache::write("test_request".time(),$this->request->data);
if($this->request->is('post'))
{
 // my code here
}
 }
}

我测试了“http://localhost/dentech/api/ecall_request" on POSTMAN successfully, But when i upload it on server at https://dentech.com/api/ecall_request 它无法访问并给出 404 错误。

htaccess 代码是:

<IfModule mod_rewrite.c>
RewriteEngine on
# Uncomment if you have a .well-known directory in the root folder, e.g. for the Let's Encrypt challenge
# https://tools.ietf.org/html/rfc5785

RewriteCond %{HTTPS} off
 RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#RewriteRule ^(\.well-known/.*)$  [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/ [L]

根据评论更新:404 错误的原因是 URL 中的控制器名称必须为大写字符。而不是

https://dentech.com/api/ecall_request

你需要使用

https://dentech.com/API/ecall_request

它在本地主机上工作而不在服务器上工作的事实是操作系统的差异。 Windows(通常在本地使用)不区分大小写,而Linux(通常是服务器OS)区分大小写。