Как я могу решить 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>
Когда я нажимаю на ссылку локальный / API / index.php / API / студент
возвращает ошибку 404
за :- http://localhost/api/index.php/api/student
ваш код должен выглядеть так …
<?php
defined('BASEPATH') OR exit('no direct script access allowed');
class api extends MY_Controller
{
function __construct()
{
parent::__construct();
}
//------------------------ Constants --------------------------
function student()
{
$student= $array = array(1=>array ('first' => 'ghali','Last_name'=>'aaaa' )
2=>array ('first' => 'aaaa' ,'Last_name'=>'bbbb' )
);
print_r( $student);
}
}
Других решений пока нет …