Hi I’m facing an issue during a technical challenge for a PHP internship using PHP 8.1 and CodeIgniter 3 (with HMVC structure using MX_Controller).
The company sent me the repository already set up — my only task is to add a login feature. However, when trying to access the login route http://localhost:8000/login
or http://localhost:8000/index.php/login
, it just loads the error page error_404.php. I keep getting the following error application->logs->log-2025-04-16.php:
ERROR - 2025-04-16 12:51:42 --> 404 Page Not Found:
../modules/acesso/controllers/Login/index
Even though the folder structure and files seem to be correct.
File Structure:
application/modules
├── acesso
│ ├── controllers
│ │ └── Login.php
│ ├── index.html
│ ├── models
│ │ └── Login_model.php
│ ├── README.md
│ └── views
│ └── login_view.php
├── framework
│ └── views
│ └── errors
│ └── cli
│ ├── error_404.php
│ └── ...
├── test
│ ├── controllers
│ │ └── Test.php
│ └── views
│ └── test.php
└── welcome
├── controllers
│ └── Welcome.php
└── views
└── welcome_message.php
Login.php:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Login extends MX_Controller {
public function index() {
echo 'Página de login';
}
}
application/config/routes.php:
$route['login'] = 'acesso/login/index';
$route['default_controller'] = 'acesso/login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
Relevant .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin: "*"
</IfModule>
I’ve been trying to solve this for 3 days and since it’s a repository that was already set up I think it should be working. I’m almost set to start at another company, but I’d really like to figure this out — it’s a question of honor at this point.
From what I can tell, the structure is correct. The Login.php file exists, with the Login class extending MX_Controller and having the index() method.
I’ve checked the routing config, capitalization of filenames, .htaccess rules, mod_rewrite… everything seems right. Still, CodeIgniter returns a 404 when trying to access the login route.
Has anyone faced this kind of issue before or knows what might be missing? Any help would be greatly appreciated