I'm using Codeigniter. I have a class MY_Controller in '/core/MY_Controller.php'
class MY_Controller extends CI_Controller
{
function __construct()
{
parent::__construct();
echo $controller = $this->uri->segment(1);
}
}
And class Login.php in \controllers\admin\Login.php
class Login extends MY_Controller{
function index()
{
echo 'login';
}
}
When i get error 404 when access http://localhost/codeigniter/admin/login/ in browser.
404 Page Not Found
The page you requested was not found.
Any ideas? What am I doing wrong? Thanks C.
TRICK
Add this code to your config file at the top may this code helps you
function __autoload($class)
{
if (strpos($class, 'CI_') !== 0)
{
if (file_exists($file = APPPATH . 'core/' . $class . '.php'))
{
include $file;
}
}
}
METHOD
You need to set Prefix in your config file
$config['subclass_prefix'] = 'MY_';
htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
ROUTES
$route['default_controller'] = 'YOUR_CONTROLLER';
$route['404_override'] = '';
$route['admin'] = "admin/login";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With