Apache 재작성은 CentOS가 아닌 FreeBSD에서 작동합니다.

Apache 재작성은 CentOS가 아닌 FreeBSD에서 작동합니다.

FreeBSD 9.2를 실행하는 5개의 프로덕션 서버가 있지만 CentOS로 전환할 계획입니다. 이 때문에 CentOS 6.6을 사용하여 프로덕션 서버 환경을 에뮬레이션하기 위해 일부 가상 머신을 설정하려고 합니다. 모든 것을 설정했고 훌륭하게 작동합니다. 단 하나의 재작성 규칙만 저장하면 됩니다.

<Directory /var/www/html/www/trunk/amapi>
  RewriteEngine on
  RewriteRule  ^$ public/    [L]
  RewriteRule  (.*) public/$1 [L]
</Directory>
<Directory /var/www/html/www/trunk/amapi/public>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</Directory>
<Directory /var/www/html/www/trunk>
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*start\.php
  RewriteRule ^start.php/?(.*)$ $1 [R=301,L]

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ start.php/$1?%{QUERY_STRING} [L]
</Directory>

처음 두 개의 재작성 규칙은 Phalcon을 사용하는 백엔드 API에 대한 것이며 두 환경 모두에서 완벽하게 작동합니다. 세 번째 재작성 규칙은 실제 파일과 일치하지 않는 모든 요청을 start.php로 리디렉션하여 Phalcon 모듈과 일치시키려고 시도한 다음 경로가 일치하지 않으면 404 페이지로 리디렉션하는 모든 요청을 포괄하는 것입니다.

어떤 이유에서인지 Apache 2.2.27을 실행하는 FreeBSD에서는 작동하지만 현재 Apache 2.2.15를 실행하는 CentOS에서는 작동하지 않습니다. 이는 두 Apache 버전 모두에서 문제 없이 작동하는 매우 간단한 재작성 규칙이지만, 파일에 액세스하려고 하면 Apache가 계속 404를 발생시킵니다. 뭔가 빠졌나요? 분명히 SSL 구성 및 특정 옵션이 표시된 코드에서 누락되었지만 이는 ssl.conf에 필수 항목이 나타나는 순서입니다.

미리 감사드립니다

업데이트: Apache Rewrite 로그는 다음과 같습니다.

10.1.1.135 - - [24/Feb/2015:17:39:17 --0500] [trunk.mydomain.com/sid#7f18f3072f98][rid#7f18f36099b8/initial] (2) init rewrite engine with requested uri /letters/custom/test
10.1.1.135 - - [24/Feb/2015:17:39:17 --0500] [trunk.mydomain.com/sid#7f18f3072f98][rid#7f18f36099b8/initial] (3) applying pattern '^/attc2/(.*)$' to uri '/letters/custom/test'
10.1.1.135 - - [24/Feb/2015:17:39:17 --0500] [trunk.mydomain.com/sid#7f18f3072f98][rid#7f18f36099b8/initial] (3) applying pattern '^/forms/(.*)$' to uri '/letters/custom/test'
10.1.1.135 - - [24/Feb/2015:17:39:17 --0500] [trunk.mydomain.com/sid#7f18f3072f98][rid#7f18f36099b8/initial] (3) applying pattern '^/grafx/(.*)$' to uri '/letters/custom/test'
10.1.1.135 - - [24/Feb/2015:17:39:17 --0500] [trunk.mydomain.com/sid#7f18f3072f98][rid#7f18f36099b8/initial] (3) applying pattern '^/xport/(.*)$' to uri '/letters/custom/test'
10.1.1.135 - - [24/Feb/2015:17:39:17 --0500] [trunk.mydomain.com/sid#7f18f3072f98][rid#7f18f36099b8/initial] (3) applying pattern '.*' to uri '/letters/custom/test'
10.1.1.135 - - [24/Feb/2015:17:39:17 --0500] [trunk.mydomain.com/sid#7f18f3072f98][rid#7f18f36099b8/initial] (4) RewriteCond: input='' pattern='!.*mydomain.com/.*$' [NC] => matched
10.1.1.135 - - [24/Feb/2015:17:39:17 --0500] [trunk.mydomain.com/sid#7f18f3072f98][rid#7f18f36099b8/initial] (4) RewriteCond: input='/letters/custom/test' pattern='\\.(jpg|gif|png)$' => not-matched
10.1.1.135 - - [24/Feb/2015:17:39:17 --0500] [trunk.mydomain.com/sid#7f18f3072f98][rid#7f18f36099b8/initial] (1) pass through /letters/custom/test

답변1

문제가 이스케이프 처리되지 않은 점인지 궁금합니다. 다음 줄을 바꿔보세요:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*start\.php

와 함께:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\.*start\.php

관련 정보