CI에서 index.php 를 줄여서 사용하기 위해서는 아파치에 mod_rewrite 모듈이 물려 있어야 가능한데요
호스팅 계정은 왠만하면 되어 있지만 단독서버의 경우 깜박하고 컴파일을 안했을경우 아래와 같이 간략하게 처리가 가능합니다.^^
(두번째줄이 핵심이고 다른 방법으로 하시면 고생하실경우도 발생~~)
아파치 소스가 /temp 폴더에 있다고 가정하고 세팅하는 모습니다.
# /temp/httpd-2.2.10/modules/mappers
# gcc -shared -Wl,-soname,mod_rewrite.so.1 -o mod_rewrite.so mod_rewrite.o
# cp mod_rewrite.so /usr/local/apache/modules
# vi /usr/local/apache/conf/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so <-- 줄 추가
# vi /usr/local/apache/conf/httpd-vhosts.conf
#mod_rewrite 설정관련
Options Indexes FollowSymLinks
#mod_rewrite 설정관련
AllowOverride All
※ 설명 : 각계정별로 .htaccess를 사용하기 위하여는 버츄얼 테이블 세팅
# vi /usr/local/apache/conf/httpd.conf
※ 각 계정별로 /home/계정/.htaccess 를 추가해서 사용
〈 CI 사용시 htaccess 세팅예 〉
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^mvc_ci.*
RewriteRule ^(.*)$ /index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
제 경우에는 이미지 디렉토리, css, js는 외부로 빼놓고 사용을 합니다.
그래서 그 디렉토리들은 위 규칙이 적용되면 안되기에 다음과 같은 라인을 추가해줍니다.
RewriteCond %{REQUEST_URI} !^/images/(.*)$