关注这个
root_folder/.htaccess
删除网址中的index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
设置基本网址
root_folder/application/config/config.php
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = 'http://[::1]/my-project/';
删除 url 中的 index.php,即使是在表单中的请求发布时
root_folder/application/config/config.php
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
s设置默认控制器,我的是 'home'
root_folder/application/config/routes.php
| controller and method URI segments.
|
| Examples: my-controller/index -> my_controller/index
| my-controller/my-method -> my_controller/my_method
*/
$route['default_controller'] = 'home';
之后,确保所有控制器文件名都是大写的。
一个也是一个类名。
当您需要实时上传时,这也很重要
服务器。
root_folder/application/controllers/Home.php
<?php
/**
*
*
* @author Lloric Garcia <emorickfighter@gmail.com>
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Home extends MY_Controller {
public function index() {
}
}
那么这就是你的网址
http://[::1]/my-project/home
这是我在实时服务器中的设置
这一切都来自
https://www.codeigniter.com/userguide3/index.html