douxi3977 2015-11-21 05:26
浏览 27

codeigniter没有检测到任何控制器

i am using codeigniter 3. i have created a simple controller and when i try to access the controller am getting the 404 error.

my controller

        <?php
        defined('BASEPATH') OR exit('No direct script access allowed');

        class home extends CI_Controller {

            /**
             * Index Page for this controller.
             *
             * Maps to the following URL
             *      http://example.com/index.php/welcome
             *  - or -
             *      http://example.com/index.php/welcome/index
             *  - or -
             * Since this controller is set as the default controller in
             * config/routes.php, it's displayed at http://example.com/
             *
             * So any other public methods not prefixed with an underscore will
             * map to /index.php/welcome/<method_name>
             * @see http://codeigniter.com/user_guide/general/urls.html
             */
            public function index()
            {
                echo "Working fine";
                $this->load->view('comman/header.php');
                $this->load->view('home/home.php');

            }
        }

config file

$config['base_url'] = 'http://localhost/annaiplan/';

$config['index_page'] = 'index.php';

$config['url_suffix'] = '';

.htaccess

Options +FollowSymLinks
RewriteEngine on

RewriteBase /annaiplan
RewriteCond $1 !^(index\\.php|resources|robots\\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

when i try to access the app am getting 404 error.

http://localhost/annaiplan/home/

enter image description here

  • 写回答

2条回答 默认 最新

  • dp19001 2015-11-21 05:41
    关注

    first always controller file name should be 'Home' and in class its class name should be Home extends.... second you need to change default controller from routes.php path to rout.php ==== root folder/application/config/routes.php

    change from $route['default_controller'] = 'welcome';to $route['default_controller'] = 'Home';

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算