Reputation: 492
I'm using REST_Controller CodeIgniter library in my project.
I have a login post method that cannot being reachable because REST_Controller is setting method as GET even if I do a POST.
Here is a snippet of my Auth.php controller:
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . '/core/REST_Controller.php';
class Auth extends REST_Controller
{
function __construct()
{
parent::__construct();
}
public function login_get()
{
echo('get');
}
public function login_post()
{
echo('post');
}
}
When I do a POST at http://localhost/auth/login using RESTED Google Chrome extension I'm getting the echo('get')
.
Debbuging REST_Controller I could see that the function _detect_method()
is returning method as GET, and this is because in the function method()
of Input core class of CodeIgniter $this->server('REQUEST_METHOD')
is returning GET.
Why is this happening?
Upvotes: 1
Views: 365
Reputation: 492
Nevermind, I got the solution!
This was happening just because I forgot to enable mod_rewrite in my Apache.
This fixes the problem:
sudo a2enmod rewrite
sudo service apache2 restart
Upvotes: 1