【问题标题】:codeigniter: removing index.php not working in xamppcodeigniter:删除 index.php 在 xampp 中不起作用
【发布时间】:2021-04-11 21:21:15
【问题描述】:

没有 index.php,我无法访问 base_url/controller/method,我尝试使用 .htaccess 删除 index.php,但仍然无法正常工作。 404 Page Not Found 但我的另一个项目在同一个 xampp 中使用相同的设置

这是我的 config.php

$config['base_url'] = 'http://localhost/sistem-informasi-bimbel/';
$config['index_page'] = '';
$config['uri_protocol']  = 'REQUEST_URI';

这是我的 routes.php

$route['default_controller'] = 'main/home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = TRUE;

这是我的 .htaccess 文件,我把它放在应用程序文件夹之外

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

在 httpd.conf 上启用了 mod 重写

LoadModule rewrite_module modules/mod_rewrite.so

【问题讨论】:

  • 设置好后重启xampp?
  • 是的,我在启用 mod_rewrite 后重新启动 xampp

标签: php .htaccess codeigniter


【解决方案1】:

这段代码非常适合我。

您需要在主控制器下创建一个gallery()。下同:

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

class Main extends CI_Controller {


    public function gallery()
    {
        $this->load->view('welcome_message');
    }
}

【讨论】:

  • 是的,我这样做了,我在主控制器中创建了 gallery()
猜你喜欢
  • 2014-08-19
  • 2017-04-04
  • 2014-08-12
  • 2013-12-29
  • 2019-01-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-10
相关资源
最近更新 更多