【发布时间】:2019-01-31 06:47:03
【问题描述】:
我的路由不工作。
我用 - https://github.com/bcit-ci/CodeIgniter/wiki/Removing-index.php-from-a-URL-path-in-XAMPP-for-Windows 删除了 index.php
我正在使用以下设置。 Codeigniter 3.1.9 的新副本
config.php
$config['base_url'] = 'http://localhost/CodeIgniter-3.1.9/';
$config['index_page'] = '';
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
routes.php
$route['hello/(:any)'] = 'hello/$1';
控制器 - Hello.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Hello extends CI_Controller {
public function __construct(){
parent::__construct();
}
public function index()
{
echo("Hello - index");
$this->load->view('welcome_message');
}
public function hello(){
echo("hello");
$this->load->view('welcome_message');
}
}
当我导航到 http://localhost/CodeIgniter-3.1.9/hello 时,它正在加载 Welcome 控制器。
日志
DEBUG - 2018-08-24 18:56:47 --> UTF-8 Support Enabled
DEBUG - 2018-08-24 18:56:47 --> No URI present. Default controller set.
DEBUG - 2018-08-24 18:56:47 --> Global POST, GET and COOKIE data sanitized
DEBUG - 2018-08-24 18:56:47 --> Total execution time: 0.0227
【问题讨论】:
-
您应该使用
http://localhost/hello网址吗? -
那不是项目工程路径。