itok's Lab

昔の開発ネタを記録として残してます

トップページを差し替える

cakePHPのトップディレクトリ (app/webroot) にブラウザからアクセスすると、デフォルトでは app/views/pages/home.thml を参照しに行きますが、いきなりなにかしらのアクションをおこしたい場合、つまり別ページを参照したい場合は app/config/routes.php を書き換えます。

app/config/routes.php : 36行目
:
$Route->connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
:

ここの controller とか action を書き換えればOK。例えば、/posts/index を表示したい場合はこんな感じ。

$Route->connect('/', array('controller' => 'posts', 'action' => 'index'));