fancy url을 사용하기 위해 요청파일이
- 없는 파일이거나
- .php확장자일 경우
- index.php로 redirect시킨다.
위 조건을 만족시키는 거였는데..
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_FILENAME} .*\.php$ [NC]RewriteRule ^(.*)$ /index.php/$1 [L]
메뉴얼을 보고 나름 이해한대로 위처럼 만들었건만 모든 요청에 대해서 rewrite rule을 타는 상황이 발생;;
리서치 결과 %{REQUEST_FILENAME}가 물리적인 풀 패스 값이 아니라서 무조건 없는 파일로 인식을 해서 그런 것이었음.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45280 에 보면
According to the documentation on http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html, the variable REQUEST_FILENAME is the full local filesystem path: "REQUEST_FILENAME The full local filesystem path to the file or script matching the request." This seems not to be the case. It seems the variable should be prefixed with DOCUMENT_ROOT to get the full path. Examples: This does not trigger the rule: RewriteCond %{REQUEST_FILENAME} -s But this does: RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -s Please update the documentation or the implementation. I lost several hours over this and I guess I'm not the only one.
나와 같은 삽질을 하던 사람이 찾아서 아파치에 수정요청 해놓은 글을 볼 수 있음.
해서
위와같이 바꿔 줌.RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-fRewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ /index.php/$1
RewriteCond %{REQUEST_FILENAME} .*\.php$ [NC]RewriteRule ^(.*)$ /index.php/$1 [L]
그리고 조건을 저렇게 나눠서 해줘야 하는데.. 플래그 [OR]로 연결하면 왜 안되는지는
모르겠음.. 그냥 조건이 여러개일 경우 저렇게 나눠줘야 한다고 이해하고 넘어감..ㅡ,.ㅡ;
