Php 为什么此控制器在代码点火器版本3.0.1中不工作?

Php 为什么此控制器在代码点火器版本3.0.1中不工作?,php,codeigniter,Php,Codeigniter,我将文件名保留为Users.php,但仍然不起作用。在类中启动契约函数 class Users extends CI_Controller{ public function index(){ echo 'hello'; } } 并运行URL作为代码>示例.COM/index .php//ux/< />代码> 请考虑 > CODENITENER命名转换< /强> ./P> 及 在config.php中 class Users extends CI_Contro

我将文件名保留为Users.php,但仍然不起作用。

在类中启动契约函数

class Users extends CI_Controller{

    public function index(){
        echo 'hello';
    }
}

并运行URL作为代码>示例.COM/index .php//ux/< />代码>

请考虑<强> > CODENITENER命名转换< /强> ./P> 及

config.php中

class Users extends CI_Controller{

    public function __construct(){
        parent::__construct();
    }

    public function index(){
        echo 'hello';
    }
}
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>
.htaccess
放在应用程序文件夹外

$config['base_url'] = '';
$config['index_page'] = '';
和在URL中

$route['default_controller'] = "users";//default controller name
http://localhost//project_name/users
注意:您不能使用任何文件扩展名访问URL,如
.php
.html


这可能会帮助您:

->app/config/routes.php

http://localhost/<path to file>/project_name/users
->app/controllers/Pages.php(注意文件上的大写字母p)

在应用程序文件夹外创建一个名为“.htaccess”的文件,并将以下代码放入其中:

$config['index_page'] = '';
这个HTaccess来自另一个名为Laravel的PHP框架,它似乎比他们在网站上提供的标准CI的HTaccess工作得更好


我希望这能帮助您。

我的默认控制器仅为“欢迎”…我在浏览器中使用此控制器时出现404错误。先阅读后尝试…仍不工作…我认为这是版本问题…可能是保存文件名的语法这件事在Codeignator中非常烦人。我尝试了很多东西仍然无法删除这个小错误。在
config.php
文件中,你的
base\u url()
是什么?@PulkitMalhotra,CodeIgniter是使用最广泛的框架之一。对于初学者来说,这是最简单的一个。请做些调查,你会知道的。
<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Pages extends MY_Controller {//Note the capital Class name
    public function homePage()
    {
        $this->load->view("pages/homepage.php");
    }
}
$config['index_page'] = '';
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]