【发布时间】:2016-02-26 09:57:06
【问题描述】:
如何解决codeigniter中的404 error
这是我的控制器 /controller/api.php
<?php defined('BASEPATH') OR exit('no direct script access allowed');
require(APPPATH.'libraries/REST_Controller.php');
class api extends REST_Controller
{
function __construct(){
parent::__construct();
}
//------------------------ Constants --------------------------
function student_get(){
$student= $array = array(1=>array ('first' => 'ghali','Last_name'=>'aaaa' )
2=>array ('first' => 'aaaa' ,'Last_name'=>'bbbb' )
);
echo $student;
$this->response($student);
}
?>
我的 .htaccess 是:
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
当我点击 url localhost/api/index.php/api/student 它返回 404 错误
【问题讨论】:
-
试试
http://localhost/api/index.php/api/student_get
标签: php .htaccess codeigniter restful-url