2017년 3월 20일 월요일

[CodeIgniter] URL에서 index.php 제거



1. httpd.conf

1) rewrite_module 활성화
#LoadModule rewrite_module modules/mod_rewrite.so
라인 주석 해제

2) .htaccess 사용을 위해 AllowOverride 옵션을 All로 변경
#AllowOverride None
AllowOverride All

- 수정 후 Apache 재시작


2. 루트 폴더에 .htaccess 파일 생성
<IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteCond $1 !^(index\.php|images|robots\.txt) # 처리를 제외할 파일이나 디렉토리를 추가
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>


3. CI config.php 수정

- index_page 수정
//$config['index_page'] = 'index.php';
$config['index_page'] = '';