3

I have a default controller set:

$route['default_controller'] = "Home";

However, when I go to http://mydomain.com/, it says 404 Page Not Found, but when going to http://mydomain.com/Home, the controller loads fine. What could be the problem? I've been wracking my head for hours. My htaccess is posted here if needed. Thanks!

arao6
  • 3,316
  • 5
  • 30
  • 51

6 Answers6

4

Turns out my problem was somewhat unrelated. I had to rename my default controller php file to lowercase and the controller class name to lowercase and everything started to work. When CI looks for the default controller file, it searches in lowercase for the file; if I name my controller file "Home.php" instead of "home.php," CI misses it on Linux (since Linux file systems are case sensitive).

arao6
  • 3,316
  • 5
  • 30
  • 51
1

There is nothing wrong with your routing, the problem is with your htaccess file. Try removing

ErrorDocument 404 /index.php
Korush Mahdavieh
  • 541
  • 5
  • 15
  • Thanks, but it still does the same thing. The default controller works when specified explicitly, but it does not load when trying to load `http://mydomain.com/`. – arao6 Jan 27 '14 at 05:07
1

You have probably some .htaccess problem. Tray this way:

.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

config.php

$config['base_url'] = 'www.homepage.com';
$config['index_page'] = '';

routes.php

$route['default_controller'] = "yourcontrollername";
$route['404_override'] = '';
Valor_
  • 3,461
  • 9
  • 60
  • 109
0

Without any additional information & code from your configs/controllers, I'd suggest checking config/config.php for these (both should be empty in normal cases):

$config['base_url'] = '';
$config['index_page'] = '';

IIRC, I have seen similar issue and it was related to these config variables. Hopefully this helps you a bit.

Kurre
  • 1
  • 1
0

I sure this .htaccess solved all ubuntu users...

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
0

I have a default controller set:

$route['default_controller'] = "home";

it's working for me.

Mujahid Bhoraniya
  • 1,518
  • 10
  • 22