dsq30861 2012-07-21 07:00
浏览 68
已采纳

更改default_controller给出404 codeigniter

I am using codeigniter 2.1.2, WAMP, im just learning it and encountered a problem. all i did was following -> created a view "home.php" with some text in it. -> created a controller "homecontroller.php" as follows:

<?php 

class homecontroller extends CI_Controller{

    function iloadhomepage(){
        $this->load->view('home');
    }
}

up till here it works fine when i run

"http://localhost/CodeIgniterTut/index.php/homecontroller/iloadhomepage"

next I changed the default controller in "routes.php" (in config) to

$route['default_controller'] = "homecontroller";

so that when i run "http://localhost/CodeIgniterTut/index.php" i would get my "home.php" but rather im getting a 404 error, am i doing a mistake anywhere? please help

  • 写回答

1条回答 默认 最新

  • dopii22884 2012-07-21 07:19
    关注

    put this in homecontroller.php

    class Homecontroller extends CI_Controller{
    
            public function index(){
                $this->load->view('home');
            }
    

    then type localhost/CodeIgniterTut/index.php,and also make every class name begin with a capital letter (thats a standard of coding).

    "The "index" function is always loaded by default if the second segment of the URI is empty,The second segment of the URI determines which function in the controller gets called". according to ci manual.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法