nginx에서 codeigniter 구동시 rewrite 설정
2016. 1. 4. 22:22ㆍTech/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;
}
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;
}
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문중 제일 최상단에 삽입 )
더 필요한 설정은 위를 응용하거나 맨위 블로그에서 참조한다.
반응형
'Tech > php' 카테고리의 다른 글
win10 on Bash(WSL)에서 php-fpm+nginx 구축시 Timedout 트러블슈팅 (0) | 2018.03.31 |
---|---|
PHP APC 이용시 클래스 redeclare 이슈 (0) | 2016.01.04 |