これに従ってください
root_folder/.htaccess
index.php
URLで削除する
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
ベース URL を設定する
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/';
index.php
フォームでのリクエスト投稿でも、URLで削除する
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'] = '';
デフォルトのコントローラーを設定します。私の場合は「ホーム」です
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() {
}
}
次に、これはあなたのURLになります
http://[::1]/my-project/home
それはライブサーバーでも私の設定です
これはすべて
https://www.codeigniter.com/userguide3/index.html