0
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[CodeIgniter]TOPページを設定する

Posted at

#CodeIgniterはじめました。

とりあえず、Welcome.phpの出力に成功。ただし、参考にした資料はここまで。
ここから一応Webアプリとして動かせるようにしたいが、流石にTopページがWelcome.phpのままはイケてない。では、どうやって変えるんだろう。

#とりあえずGrep

C:\CI\CodeIgniter-3.0.6\application\config\routes.php(30,35)  [SJIS]: |	$route['default_controller'] = 'welcome';
C:\CI\CodeIgniter-3.0.6\application\config\routes.php(33,52)  [SJIS]: | URI contains no data. In the above example, the "welcome" class
C:\CI\CodeIgniter-3.0.6\application\config\routes.php(52,33)  [SJIS]: $route['default_controller'] = 'welcome';
C:\CI\CodeIgniter-3.0.6\application\controllers\Welcome.php(4,7)  [SJIS]: class Welcome extends CI_Controller {

・
・
・
362 個が検索されました。

$route['default_controller'] = 'welcome';
すごくそれっぽい。

#application\config\routes.php!貴様か!
正解かどうか、編集してみよう。

application\config\routes.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
**********************************コメント省略**********************************
| Examples:	my-controller/index	-> my_controller/index
|		my-controller/my-method	-> my_controller/my_method
*/
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

'welcome'を'wel'に。Welcome.phpと同じディレクトリにWel.phpを設置。

application/controllers/Wel.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Wel extends CI_Controller {

        public function index()
        {
                echo "AAAAAAAAAAAAAAAAAAA";
        }
}

#結果
想定通り!
image.png

これからもうちょっといじっていきます。

0
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?