代码点火器URL显示404


Codeigniter URLs showing 404

我有一个简单的web托管平台。我正在/var/www/html上托管一个Codeigniter应用程序意味着这是文件结构:

html 
|-application
|---controllers
|---models
|---views
|---config
|-public
|-system
|-index.php
|-.htacess

我的.htaccess文件如下:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

在我的config.php文件中,我的默认根视图控制器为:

$config['base_url']     = 'http://www.example.com/';

在routes.php文件中,我有

$route['default_controller'] = "home"

因此,当我在浏览器中打开www.mysite.com时,我自然会自动返回主页/索引。但当我尝试任何其他URL时,如

www.example.com/home
www.example.com/home/index
www.example.com/admin

我得到一个404错误。同样值得注意的是,这个文件夹在我的本地机器和我尝试过的另一台远程服务器上运行得很好。

更准确地说,当我尝试www.example.com/home时,我得到了这个错误

Not Found
The requested URL /home was not found on this server.

编辑

我的家庭控制器是这样的。

class Home extends CI_Controller{
    public function __construct() {
        parent::__construct();
    }
    public function index(){
        $this->load->view('home_view');
   }
    public function someFunction(){
       echo 'In some function';
    }
}

编辑

我不知道这是否有帮助,但在URL中添加index.php似乎可以像预期的那样打开页面。所以

www.example.com/controller/function (DOES NOT WORK)
www.example.com/index.php/controller/function (WORKS)

请帮忙吗?

您需要为路由文件中的不同url指定操作。与site.com/search类似,将其添加到$route['default_controller']="home",之前

$route['search'] = "home/search"

这意味着,你将在你的家庭控制器中创建一个函数搜索,它将加载指定url的视图文件。