Codeigniter 2.0 default controller for sub folder

2019-08-15 20:01发布

I have set up a virtual host in my local machine (assume it to be http://local.he). I have a home.php in the main ‘controllers’ folder. I have two subfolders inside the ‘controllers’ folder and they are ‘admin’ and ‘wori’ and each has a home.php file.

Per CI 2.0 structure, if I access http://local.he/module/wori then it should load home.php from ‘wori’ and it is working but when I did the same in the server after uploading the files it always loads from module. Even if I access something like this: http://site.com/module/wori/users, it is still loading the home.php from module.

Here is the .htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|images|js|css|static)
RewriteRule ^(.*)$ index.php/$1 [L]

Here is the routing and these two are the only executable lines in routes.php

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

When I try to access http://site.com/module/index.php/wori or http://site.com/module/index.php/wori/users then it works. I checked .htaccess and it is working for other modules in my site. I even tried this example: CodeIgniter default controller in a sub directory not working but this is still not working:

$route['wori'] = 'wori/home';

Can anyone tell me what is missing?

1条回答
混吃等死
2楼-- · 2019-08-15 20:23

I followed the answer from the following url and it worked for me.

http://codeigniter.com/forums/viewthread/181149/#857629

yet would like to know why it was working normally like in the localhost.

查看更多
登录 后发表回答