Mengatasi Problem Routes pada Codeigniter dengan Target Direct ke Sebuah Folder



Tulisan ini diambil dari suber sebuah Forum ternama stackoverflow.com 

PROBLEM
My default_controller in the routes configuration is set as "home.php".
I have a sub directory for my controllers, lets call it "folder". So if I visit http://mysite.com/folder/, the default controller "folder/home.php" should be called right?
However for some reason this doesn't work, I get a 404. Visiting http://mysite.com/folder/home or http://mysite.com/folder/home/index works as expected. In addition to this, the default controller works in the root directory (http://mysite.com loads home.php).
Any ideas, has anyone else experienced this? I can't get my head around it - it would appear to be a CI issue but I can't find anybody else having the same problem.
The documentation, from the way I understand it at least, suggests that this should work fine: http://codeigniter.com/user_guide/general/controllers.html#subfolders
Setting the default controller to "folder/home.php" means that http://mysite.com/folder/ works fine as expected. Except for I want the default controller to just be "home.php" - whether in the root or in a sub directory, home.php within that directory should be loaded, as the documentation suggests

SOLUSI / JAWABAN
In application/config/routes.php just add this
$this->set_directory( "user" );
$route['default_controller'] = 'home/index';

Share on Google Plus

About Elmirakom

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment