douhao2721 2013-06-06 15:34
浏览 50
已采纳

找不到CodeIgniter对象只有索引函数有效

I am new to CodeIgniter, everything was going fine and well up until I found out that I can only make a call to the index() function.

I have setup the config.php, autoload.php and routes.php as expected.

on the config.php

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

on the autoload.php

$autoload['helper'] = array('form','url');

on the routes.php

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

I have a controller named site

<?php

    class Site extends CI_Controller{

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

        function new_method(){
            $this->load->view('home2');
        }
    }
?>

I have to 2 files on the view folder with their HTML code, simply named home.php and home2.php

on home.php I have

<?php 
    echo form_open('site/new_method');
    echo form_submit('submit', 'call method'); 
    echo ('<br /><br />');
    echo anchor('site/new_method', 'call method');
    echo form_close();
?>

The index() loads, as results U get a button and a link but when I click I am given Object not found! Error 404

  • 写回答

4条回答 默认 最新

  • dougu6815 2013-06-06 16:32
    关注
    1. You can make this empty $config['base_url'] = '';
    2. Check .htaccess in root folder with index.php file
    3. Check mod_rewrite apache module is enabled

    RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题