1

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?

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

2 Comments

strange!! it should show you 404 error. since your mod_rewrite was disabled and your URL didn't have index.php like,http://localhost/index.php/auth/login
@jagad89, true. I don't know why I didn't have 404. If I got, it would be easier to get to know that it was a mod_rewrite problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.