Codeigniter 3 index method behaving unexpectedly

Hers is an idea - add this after you have loaded the session object:

    if ($this->session->userdata("username") && $this->router->method == "index") {
            redirect(base_url("dashboard/"));
    }

Please use this .htaccess

RewriteEngine On 
RewriteCond %{REQUEST_URI} ^/system.* 
RewriteRule ^(.*)$ index.php?/$1 [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)$ index.php?/$1 [L]


if you visiting sub.example.com/index.php successfully then try this

public function login()
{
    $data = $this->default_data;
    if ($_POST) {
        $username = $this->input->post("username");
        $plain_password = $this->input->post("password");
        $this->load->model("authenticate");
        if (!$this->authenticate->auth($username, $plain_password)) {
            $data['message'] = "Invalid Credentials";
        }else{
            //go to dashboard function
            $this->index();
        }
    }
    $this->load->view('login', $data);
}