I write a controller in CakePhp-2.9 named API to access outside. Controller Code:
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
}
}
}
And i tested "http://localhost/dentech/api/ecall_request" on POSTMAN successfully, But when i upload it on server at https://dentech.com/api/ecall_request it does not access and gives 404 error.
htaccess code is:
<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/.*)$ $1 [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
Updated from comments: The reason for the 404-error is that the controller name in the URL has to be in uppercase characters. Instead of
You need to use
The fact that it works on localhost but not on the server is the difference in the operating system. Windows (often used locally) is not case-sensitive, while Linux (usually the servers OS) is case-sensitive.