Codeigniter 2.0 子文件夹的默认控制器不在服务器中工作但在本地主机中工作

发布于 2024-12-23 04:09:30 字数 1438 浏览 3 评论 0原文

我已经在本地计算机上设置了一个虚拟主机(假设它是 http://local.he)。我的主“controllers”文件夹中有一个 home.php 。我的“controllers”文件夹中有两个子文件夹,它们是“admin”和“wori”,每个子文件夹都有一个 home.php 文件。

根据 CI 2.0 结构,如果我访问 http://local.he/module/wori 那么它应该从“wori”加载 home.php 并且它正在工作,但是当我上传文件后在服务器中执行相同操作时,它总是从模块加载。即使我访问这样的内容: http://site.com/module/wori/users,它仍在从模块加载 home.php

这是 .htaccess

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

routes.php 中唯一可执行的行

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

这是路由,当我尝试访问 http://site.com/module/index.php/worihttp://site.com/module/index.php/wori/users 然后就可以了。我检查了 .htaccess ,它适用于我网站中的其他模块。我什至尝试过这个例子: CodeIgniter 默认控制器在子目录中不工作但这仍然不起作用:

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

任何人都可以告诉我缺少什么吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往日 2024-12-30 04:09:30

我按照以下网址的答案进行操作,它对我有用。

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

还可以想知道为什么它像在本地主机中一样正常工作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文