CI 묻고 답하기

제목 URI에서 index.php 제거하기
글쓴이 Mark 작성시각 2011/02/11 19:01:23
댓글 : 1 추천 : 0 스크랩 : 0 조회수 : 29902   RSS

PHP를 시작한지 얼마안되는데,  codeigniter를 접하게 되었습니다. 
제 환경은
 apache2.x + MySQL5.x + PHP5 + codeigniter 1.7.2  (AMP는 xampp로 설치)

 URI에서 index.php를 제거하고 싶어서 여기 저기 검색을 해보니 참고자료가 많이 있더군요. 여러가지 문서를 읽고
그래도 따라서 했는데도 아직  404에러가 나오는데요.

현재 Directory 구조는 이렇습니다.
 c:\xampp\htdocs\ci ->여기가 CI가 설치된 폴더이구요.
                                   \system\application
                                  기타 폴더

codeigniter 압축풀어서 codeingniter폴더를  c:\xampp\htdocs\ 에 copy한 다음  폴더명을 ci 로  rename했습니다.

그리고 \ci\system 폴더에 .htaccess 파일을 생성했습니다. .htaccess의 내용입니다.

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 # Hide the application and system directories by redirecting the request to index.php
 RewriteCond $1 !^(index\.php|resources|robots\.txt)
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php\
</IfModule>

apache에 있는 config.php 에서 

$config['index_page'] = ""; 
$config['uri_protocol'] = "REQUEST_URI";

로 변경했습니다. $config['index_page'] = "index.php";로도 설정해서 해봤습니다.)

CI를 깔고 나서는 http://localhost/ci 로 접속하면 http://localhost/index.php 로 URL이 변경되면서 잘 접속이 됐습니다.
그리고 controller 밑에 blog.php파일 생성해서 echo "Hello World!"를  출력하는 것 까지는 잘 되었습니다.( http://localhost/ci/index.php/blog/  로 접속)

그런데 .htaccess 파일을 수정하고 apache를  restart  하고 부터는 404 에러만 출력됩니다. 

 어떤 부분을 점검해야 할까요?


 

태그 URI,index.php,URL,mod_rewrite
 다음글 CI에서의 폴더구조?? (2)
 이전글 widget사용시 (1)

댓글

변종원(웅파) / 2011/02/11 23:20:38 / 추천 0
.htaccess 파일은 index.php 파일이 있는 곳에 복사해야 합니다.