Codeigniter: 404 Page Not Found on Live Server

CodeIgniter: 404 Page Not Found on Live Server

You are using MVC with OOPS Concept. So there are some certain rules.

1) Your class name (ie: controller name) should be start with capital Letter.

e.g.: your controller name is 'icecream'. that should be 'Icecream'

In localhost it might not be compulsory, but in server it will check all these rules, else it can't detect the right class name.

Codeigniter 404 Error On Live Server

Your Base URL should be

$config['base_url'] = 'http://cyfers.com/moving/';

In htaccss

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

Your Controller file should be dashboard.php.

And default controller should be $route['default_controller'] = "dashboard";


To hide errors on site in root there is file call index.php

Change this to

define('ENVIRONMENT', 'development');

this

define('ENVIRONMENT', 'production');

CodeIgniter 404 Page Not Found, but why?

The cause of the problem was that the server was running PHP using FastCGI.

After changing the config.php to

$config['uri_protocol'] = "REQUEST_URI";

everything worked.

Custom 404 not showing in Codeigniter on live server

Try to lowercase the controller name in your route:

$route['404_override'] = 'my404';

Report back if that doesn't solve your problem.

Regarding what to do if you need to customize the 404 generated when there is no matching route, I've created a file /application/core/MY_Exception.php:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class MY_Exceptions extends CI_Exceptions {

/**
* Class constructor
*/
public function __construct()
{
parent::__construct();
}

// --------------------------------------------------------------------

/**
* 404 Error Handler
* -----------------
* This method has been extended so that if we use the show_404
* function, that it is a styled/custom 404 page that is shown.
*/
public function show_404( $page = '', $log_error = TRUE )
{
if( is_cli() )
{
$heading = 'Not Found';
$message = 'The controller/method pair you requested was not found.';
}
else
{
$heading = '404 Error - Page Not Found';
$message = 'The page or resource you were looking for was not found on this server.';
}

// By default we log this, but allow a dev to skip it
if( $log_error )
{
log_message('error', $heading . ': ' . $page );
}

if( is_cli() )
{
echo $this->show_error($heading, $message, 'error_404', 404);
}
else
{
$CI = &get_instance();

$CI->output->set_status_header('404');

$view_data = [
'heading' => $heading,
'message' => $message
];

$data = [
'doc_title' => ['pre' => '404 Error - Page Not Found - '],
'extra_head' => '<meta name="robots" content="noindex,nofollow" />',
'content' => $CI->load->view( 'errors/html/error_404', $view_data, TRUE )
];

$CI->load->view('templates/main', $data);

echo $CI->output->get_output();
}

exit(4); // EXIT_UNKNOWN_FILE
}

// --------------------------------------------------------------------

}

Notice that the way I've done it, I'm nesting the error_404 view inside a template that I created. That's just the way I do it. You'd replace that part with what you use when you create pages in your application (usually your controller).

CodeIgniter: 404 Page not found after push for server

The error was: in controllers was like that: user.php so i renamed for User.php, i not understand well that, but fixed online my code.

using user.php run in my local but not in live, if somebody know why, please leave a comment too.

thanks all for the help.

cheers.

live server shows 404 error, but not on local, codeigniter 3

Answering this for the others who might come across the same problem.

Okay so user Don't Panic suggested I echo just "question x" in the problematic controller, and when I did that, the 404 error went away and it echoed the "question x." So definitely it's my controller that has the problem and not my routine or .htaccess files.

Now this controller is designed in such a way that it calls first an ID from the database before it shows anything. After I echoed "question x" I realized that the ID it is calling from my database has a value of zero. So, unsurprisingly, from the controller's point of view, the page doesn't exist! Hence the 404.

I've fixed it now by updating that table from my database and giving the ID a value it should already have had in the first place.

Why Codeigniter Gives 404 Page not found error on server?

You'll also have to set the $config['base_url'] to your domain name.



Related Topics



Leave a reply



Submit