CI 묻고 답하기

제목 mod_rewrite 사용시 경로설정은 어떻게들 하시나요?
글쓴이 아날로직 작성시각 2009/04/07 16:39:09
댓글 : 6 추천 : 0 스크랩 : 0 조회수 : 30091   RSS
메뉴얼에서
CI 에서의 URL 규칙 CodeIgniter URLs
여기보면
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

이거 사용하라고 되어있는데, 저렇게 해서 사용할때 이미지라든가 css 라든가 전혀 불러올수가 없는데요.
다들 어떻게들 사용하시나요?
 다음글 내일 서버셋팅이 됩니다. 포럼명칭 추천 바랍니다. (7)
 이전글 func_get_args() (3)

댓글

kirrie / 2009/04/07 16:47:08 / 추천 0

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} ^system.*
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]


.htaccess 파일을 위 스크립트로 교체하고 system/applications/config/config.php 에서 $config['index_page'] = 'index.php' 를 ''로 변경해주시면 됩니다.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

요 두 구문은 디렉토리나 파일이 실제 존재하면 해당 파일을 서빙하고 그렇지 않으면 request uri를 index.php로 고쳐쓰라는 의미입니다.
아날로직 / 2009/04/07 17:25:29 / 추천 0
와~ 빠른 답변 감사합니다.
근데 저는 뭔가 근본적인 문제가 있나봅니다.;;
삽질의 연속이군용.
Cacti / 2009/04/07 17:36:27 / 추천 0
일반적으로 웹로그 error_log 파일을 보면 에러를 확인하실 수 있습니다.
에러내용을 보면 해결방법이 어느 정도 보이리라 생각합니다.
물론 에러로그파일을 볼 수 있는 권한이 있어야겠죠.
변종원(웅파) / 2009/04/07 17:37:30 / 추천 0
RewriteCond와 RewriteRule 의 순서가 틀리면 적용이 안됩니다.
저는 다음과 같이 쓰고 있습니다.
images, include, data, layouts, views 디렉토리는 적용제외입니다.


RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/images/(.*)$
RewriteCond %{REQUEST_URI} !^/include/(.*)$
RewriteCond %{REQUEST_URI} !^/data/(.*)$
RewriteCond %{REQUEST_URI} !^/layouts/(.*)$
RewriteCond %{REQUEST_URI} !^/views/(.*)$

RewriteRule ^(.*)$ /index.php/$1 [L]
아날로직 / 2009/04/07 17:53:22 / 추천 0
웅파님 방법으로 일단 해결은 됐습니다.
우분투데스크탑에 APM 깔아서 쓰고 있는데요.
.htaccess 파일을 만들면 자꾸 403 에러가 떠서
httpd.conf 파일을 편집해서 mod_rewrite 를 쓰고 있었습니다.
답글 감사합니다;;
corean / 2009/09/04 02:57:00 / 추천 0
일본사이트 예제에는
RewriteEngine on
RewriteCond $1 !^(index\.php|css|user_guide|.+\.gif$|.+\.jpg$|.+\.png$|.+\.js$)
RewriteRule ^(.*)$ index.php/$1 [L]

물론,
config.php의 $config['index_page'] = "";