• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Default controller doesn't appear to be working

My local development site in MAMP works fine, put it on my live hosting in a subfolder for testing and I get 404 errors when I don't pass a controller.


http://www.website.com/dev/ <-- 404
http://www.website.com/dev/Blog <-- Works correctly

I'm using this .htaccess to remove index.php from the URI:

RewriteEngine On

# Have tried with and without RewriteBase
RewriteBase /dev/

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

Hosting definitely supports mod_rewrite, I have other stuff on there using it - including a Wordpress install that uses a very similar rewrite.

I've printed out the $_SERVER variable and it shows that it's going for the right script (http://www.website.com/dev/index.php)

In config I've set everything up like (I think) it should be, relevant parts are:

$config['base_url']    = "http://www.website.com/dev/";
$config['index_page'] = "";

And in routes I have

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

Any idea what might be wrong? Hoping it's something simple, this is driving me crazy!


Instead of this:
$config['base_url']    = "http://www.website.com/dev/";

Try this

$config['base_url']    = "http://www.website.com/dev";

remove the backslash at the end then it should works

Thanks for the reply. Still getting 404 error though!
I'm sure it will be something that simple but I just can't see what could be wrong.

I've removed the .htaccess file entirely, changed the config to this:

$config['base_url'] = "http://www.website.com/dev";
$config['index_page'] = "index.php";

Now I get these results:

http://www.website.com/dev/index.php <-- 404
http://www.website.com/dev/index.php/Blog <-- Works

I'll keep hunting, in the meantime any suggestions are appreciated.


Changed controller filename and default controller to lowercase.

I guess it was getting confused with the actual filename (Blog) and the class Blog?

Anyway, all working as expected now.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.