各種設定

ベースURLの設定

  • application/config/config.php
<?php

$config['base_url'] = 'localhost';

デフォルトコントローラの設定

  • application/config/routes.php
<?php


$route['default_controller'] = "welcome";

base_urlを有効にする

対処法

config/autoload.phpの60行目辺り。

$autoload['helper'] = array();

'url'を追加する(以下は一例)

$autoload['helper'] = array('url', 'view', 'security');

”index.php”をURLから消す

初期では、

localhost/hchuno/index.php/blog/

のように、index.phpがURLの中に含まれるようになっているので、これを削除する。

まず、.htaccessを作成

RewriteEngine on
RewriteCond $1 !^(index\.php|image|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
$ vim /etc/apache2/httpd.conf

ひとまず”AllowOverride None”となっている箇所を”AllowOverride All”とすれば良いが、DocumentRootのDirectoryタグ内の”AllowOverride”に手を加える。
これで、

localhost/hchuno/blog/

のようなURLになった。