dtebrq0245 2015-08-17 21:37
浏览 56

CodeIgniter控制器模型404错误

I'm getting a 404 error on my CodeIgniter site, I've had a look around at the other answers and playing with the .htaccess but yet to solve. Its located on my domain.co.uk/admin

Controller -

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

class Projects extends CI_Controller {

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

public function index() {
    $this->load->model('project');
    $data['projects']=$this->project->get_projects();
    echo"<pre>";print_r($data['projects']);echo"</pre>";
}
}

Model -

<?php

class Project extends CI_Model{

function get_projects($num=10,$start=0){
    $this->$db->select()->from('projects')->where('active',1)->order_by('date_added','desc')->limit($num,$start);
    $query=$this->db->get();
    return $query->result_array();
}
}

I've also added these routes -

$route['default_controller'] = 'projects';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

Currently have this .htaccess in my domain/admin folder

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Can anyone see why I might be getting a 404 error

  • 写回答

3条回答 默认 最新

  • douwengzao5790 2015-08-18 00:20
    关注

    What do you have on your $route['default_controller'] variable? (It shoulds be defined in \application\config).

    If you have $route['default_controller'] = "Projects", your index URL should be domain/admin/index.php/projects or domain/admin/projects*

    *You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected except the specified items:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
    $config['index_page'] = '';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等