dongpi3237 2019-08-09 11:41
浏览 106
已采纳

除了default_controller之外,在所有控制器上获取错误404

I am trying to setup a new application using Codeigniter.

When i am defining the routes, i get an error 404 in all of them, except on default_controller.

I didn't change the .htaccess file and i can't access directly the controllers.

How do i fix this? I never had this error before on CI

HTACCESS

<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>

Config

$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/CodeIgniter/core/';

$config['index_page'] = 'index.php';

Controller:

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

class Utilizador extends CI_Controller {
    function __construct(){
        parent::__construct();
        $this->load->library('session');
    }

    public function index(){
        //print_r($this->Utilizador_model->teste());
        echo "pppp";
    }

    }


?>

Routes:

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

HTML:

<div class="container">
  <div class="row">
    <div class="col-md-4 col-sm-6 col-xs-12 col-md-offset-4 col-sm-offset-3">
      <div class="bslf form">
        <form action="<?= base_url('utilizador') ?>" method="post">
          <h2 class="text-center">Login</h2>       
          <div class="form-group">
             <input type="text" class="form-control" placeholder="Username" required="required">
          </div>
          <div class="form-group">
            <input type="password" class="form-control" placeholder="Password" required="required">
          </div>
          <div class="form-group clearfix">
            <button type="submit" class="btn btn-primary pull-right">Log in</button>
          </div>       
        </form>
      </div>
    </div>
  </div>
</div>
  • 写回答

1条回答 默认 最新

  • duandou1903 2019-08-09 11:46
    关注

    Update you .htaccess

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 ue5运行的通道视频都会有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数