doushangan3690 2017-01-26 11:28
浏览 23

在codeigniter中找不到服务器上的控制器功能

So I got exactly this 404 error :

Not Found

The requested URL /adminigniter1/Usercontroller/insert was not found on this server.

Apache/2.4.18 (Ubuntu) Server at localhost Port 80

When I wanted to call a function from the controller, from what I read about it has to do with the the .htaccess file(and I placed that in my source folder adminigniter1), but mine seems to look ok:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /adminigniter1/index.php
</IfModule>

From my index.php I send to that controller function like this:

<form method = "POST" action = "<?php echo base_url('Usercontroller/insert') ?>">

And this is my controller :

<?php

class Usercontroller extends CI_Controller {
function __construct() {
    parent::__construct();
    $this->load->model('Usermodel');

}
public function index() {
    $data["content"]= "user/index";
    $data["getStatus"] = $this->Usermodel->getStatus();
    $this->load->view("main",$data);
}
public function insert() {
    $datai= $this->input->post();

    if(isset($datai)){
        echo $datai['txtApartament'];
        exit;
    }
}

}

What can be wrong ?

  • 写回答

1条回答 默认 最新

  • dongqian1893 2017-01-26 13:49
    关注

    Ok, I found the reason for that, I will post it here since some one can have this problem. All the issues were on apache2 side:

    If you use ubuntu go :

    sudo gedit /etc/apache2/apache2.conf
    

    There you will have to edit field like this :

    <Directory /var/www/html/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    

    In my case AllowOverride was set to None, so you will have to set it to All, another thing, check the root for your localhost /var/www/html/ in my case, to be ok!

    评论

报告相同问题?