# CodeIgniter 控制器 - 定义默认控制器

**URL:** <https://www.isharkfly.com/t/codeigniter/2872>\
**Category:** PHP\
**Created:** [January 5, 2014, 1:14am UTC](https://www.isharkfly.com/t/codeigniter/2872 "2014-01-05T01:14:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [January 5, 2014, 1:14am UTC](https://www.isharkfly.com/t/codeigniter/2872/1 "2014-01-05T01:14:16Z")

</div>

当你的网站不存在某个URI 或者 用户直接从根目录访问的时候，CodeIgniter 会加载默认控制器。

打开 application/config/routes.php 文件来设置默认控制器：`$route['default_controller'] = 'Blog';`这里的 Blog 就是你希望使用的控制器的名字。如果此时你不指定任何 URI 片段来访问你的主页就会看到默认的“Hello World”信息。
