Reputation: 3376
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!
Upvotes: 3
Views: 11129
Reputation: 1584
I have a default controller set:
$route['default_controller'] = "home";
it's working for me.
Upvotes: 0
Reputation: 21
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]
Upvotes: 0
Reputation: 3376
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).
Upvotes: 4
Reputation: 3591
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'] = '';
Upvotes: 1
Reputation: 1
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.
Upvotes: 0
Reputation: 541
There is nothing wrong with your routing, the problem is with your htaccess file. Try removing
ErrorDocument 404 /index.php
Upvotes: 1