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!

1
  • Your .htaccess file looks fine. Try small letters like $route['default_controller'] = "home"; and see if it makes difference Commented Jan 27, 2014 at 5:14

6 Answers 6

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).

Sign up to request clarification or add additional context in comments.

Comments

1

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

ErrorDocument 404 /index.php

1 Comment

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/.
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'] = '';

Comments

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.

Comments

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]

Comments

0

I have a default controller set:

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

it's working for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.