nginx에서 codeigniter 구동시 rewrite 설정

2016. 1. 4. 22:22Tech/php

728x90
반응형

http://www.farinspace.com/codeigniter-nginx-rewrite-rules/

아주 잘 설명되있다.

아래 구문을 /site-available/default에 적용한다.

[cc lang="php"]
# removes access to "system" folder, also allows a "System.php" controller
if ($request_uri ~* ^/system)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
[/cc]

기본적으로 URI세그먼트를 이용해 접근시에 index.php를 타도록 한다.

[cc lang="php"]
# removes access to "system" folder, also allows a "System.php" controller
if ($request_uri ~* ^/js)
{
rewrite ^/js/(.*)$ /js/$1 last;
break;
}
[/cc]

따로 필요한 스크립트, 이미지폴더 등은 예외지정해준다.

( 먼저 처리되야 하므로, 위 설정보다 앞에다 구문을 삽입한다. )

[cc lang="php"]

 if ($request_uri ~* ^/system) {
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}

[/cc]

   

system 등 접근되지 말아야할 폴더에도 적용한다.

( 마찬가지로 rewrite if문중 제일 최상단에 삽입 )

더 필요한 설정은 위를 응용하거나 맨위 블로그에서 참조한다.

반응형