Welcome Guest, Not a member yet? Register   Sign In
Default controller in index.php & routes.php
#1

[eluser]Unknown[/eluser]
I set the default controller/function in index.php. This feature really solve a lot of coding effort for my old sites.

It used to work and today it stop working. I kept getting 404 page not found.

After debugging, I notice that the name of default controller coded in routes.php, is pointing to an invalid controller name (I renamed that controller today).
I changed the default controller in routes.php to some valid controller name and my index.php works again.

Even though CI is using the default controller in index.php, somehow CI still check for the default controller in routes.php

2 points to note if you set default controller in index.php
1) The default controller in routes.php must be valid
2) Always set 3 variables in index.php. Initially I did not set $routing['directory'] and it does not work.
- $routing['directory']
- $routing['controller']
- $routing['function']

Just to share my experience because I benefited a lot from this forum.

#2

[eluser]Aken[/eluser]
Why are you adding default controller code to the index.php file? Just set the default_controller route and you're fine...
#3

[eluser]PhilTem[/eluser]
@Aken
Why shouldn't he set it in index.php? EE has a part where you can set it, so there's no need for routes in that case.

@uzoom
I get/got the same problem. Your post kinda solves my post, even though not it's not a official bug-fix.
Should give you fix a try today.
#4

[eluser]Aken[/eluser]
Yes you CAN set it in EE, but it says right above it "END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE". So obviously you want to be really sure of what you're doing.

Anyway, I'm asking because setting a default route in index.php is rare and typically completely unnecessary. Read the comments right above it, which explain why it is not common and the precautions you'll need to take. If all he's trying to do is set the homepage, it's totally unnecessary to edit index.php.




Theme © iAndrew 2016 - Forum software by © MyBB