用于子文件夹的Codeigniter 2.0默认控制器在服务器中不起作用,但在本地主机中起作用 [英] Codeigniter 2.0 default controller for sub folder not working in server but working in localhost

查看:84
本文介绍了用于子文件夹的Codeigniter 2.0默认控制器在服务器中不起作用,但在本地主机中起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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.

这是 .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/wori http://site.com/module/index.php/wori/users 即可。我检查了 .htaccess ,它在我网站中的其他模块上都有效。我什至尝试了以下示例:不在子目录中的CodeIgniter默认控制器工作,但仍然无法工作:

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?

推荐答案

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

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.

这篇关于用于子文件夹的Codeigniter 2.0默认控制器在服务器中不起作用,但在本地主机中起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆