웹프레임워크 | CodeIgniter - index.php 제거

웹프레임워크 | CodeIgniter - index.php 제거

주소가 늘어지고 가독성이 안 좋기 때문에 index.php를 제거

아파치가 mod_rewrite를 지원해야 함

아파치 mod_rewrite에 관한 글은 다음 글을 참고

최상위 디렉토리에 코드이그나이터를 설치한 경우

http://내홈피주소/index.php/컨트롤러/함수/변수값

http://dovetail.dothome.co.kr/index.php/welcome/hello/1

application 폴더와 system 폴더, index.php 파일이 위치한 디렉토리에 .htaccess 파일

RewriteEngine On RewriteBase / RewriteCond $1 !^(index\.php|images|captcha|data|include|uploads|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L]

아래와 같은 하위 디렉토리에 설치한 경우

http://내홈피주소/어떤폴더/저런폴더/이런폴더/index.php/컨트롤러/함수/변수값

http://dovetail.dothome.co.kr/어떤폴더/저런폴더/이런폴더/index.php/welcome/hello/1

하위 디렉토리에 위치한 경우에는 다음과 같은 코드를 사용

RewriteEngine On RewriteBase /

RewriteCond $1 !^(index\.php|images|captcha|data|include|uploads|robots\.txt)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ 어떤폴더/저런폴더/이런폴더/index.php/$1 [L]

from http://sanctacrux.tistory.com/555 by ccl(A) rewrite - 2020-04-02 15:01:36