[CI] 경로 중 index.php 제거
ci 를 이용하여 프로젝트를 진행하다보면 경로 중간에 index.php 가 붙는 것을 볼 수 있다.
보기에도 좋지 않고 은근 거슬린다.
경로에 index.php 를 제거하는 방법은 다음과 같다.
-
ci 프로젝트 최상위 폴더(디렉토리)에 .htaccess 파일 생성
-
다음 내용 입력
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond $1 !^(index\.php|css|js|images|captcha|data|include|uploads|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
<IfModule>
만약 https 를 사용한다면 .htaccess 를 다음과 같이 적용한다.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://{도메인 주소}/$1 [R,L]
RewriteBase /
RewriteCond ${REQUEST_URI} !^(index\.php|css|js|images|captcha|data|include|uploads|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
<IfModule>