Efekan
Efekan

Reputation: 1505

Codeigniter project works local but not online - 404 page not found

As the title says I have searched a lot, tried some fixes yet it still is not working on online server. Online I keep receiving 404 Page not found. When its run locally it works like a charm.

Currently this is my configuration.

public_html/application/config/config.php:

$config['base_url'] = '';

$config['index_page'] = '';

$config['uri_protocol'] = 'AUTO';

I've tried changing the base_url to the sites domain: http://junkfoodmountain.com/
Tried changing index_page to index.php and to nothing
Tried changing the uri_protocol to every other possible one.

public_html/.htaccess

Options -Indexes

RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|assets|phpmyadmin|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [QSA,L]

Tried not using the .htaccess not working either.

The server is a Ubuntu Server 14.04 LTS with virtualmin. All configuration on this is on default. Ofcourse when you go to the site link it shows everything thats in the public_html


UPDATE 1:
After doing a fresh installation. It all works on default. And adding the files 1 by 1 I found out it has do with the routes.php. Changing the

$route['default_controller'] = 'welcome';

To

$route['default_controller'] = 'main/index';

This is the main.php

<?php
class main extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('home_model');
    }

    public function index($page = 'home')
    {
        $menu['menu'] = $this->home_model->get_menu();
        $data['servers_table'] = $this->servers_table($this->home_model->get_servers());


        $this->load->view('templates/header', $menu);
        $this->load->view('pages/'.$page, $data);
        $this->load->view('templates/footer');
    }
}

Upvotes: 3

Views: 2046

Answers (3)

rheem
rheem

Reputation: 1

I had the same problem. I just renamed the controller name to all lowercase characters from Home to home.

Upvotes: 0

Efekan
Efekan

Reputation: 1505

I've found out that you should call your Controllers with uppercase as its first letter. Changing the

main.php > Main.php

and

class main extends CI_Controller > class Main extends CI_Controller

Fixed the problem for me

Upvotes: 2

Baris
Baris

Reputation: 59

You could try to change the values on .htaccess file. Once, I had the same and then I could solve it with .htaccess. I don't remember exactly what I did on it. I can't say about the changing

Upvotes: 0

Related Questions