Apache rewrite は CentOS ではなく FreeBSD で動作します

Apache rewrite は CentOS ではなく FreeBSD で動作します

私は FreeBSD 9.2 を実行している 5 台の運用サーバーを所有していますが、CentOS への移行を計画しています。このため、CentOS 6.6 を使用して運用サーバー環境をエミュレートする仮想マシンをいくつかセットアップしようとしています。すべてをセットアップし、1 つの書き換えルールを除いて問題なく動作しています。

<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>

最初の 2 つの書き換えルールは、Phalcon を使用するバックエンド API 用であり、両方の環境で完璧に機能します。3 番目の書き換えルールは、実際のファイルと一致しないすべてのリクエストを start.php にリダイレクトするキャッチオールです。start.php は、リクエストを Phalcon モジュールに一致させようとし、一致するルートがない場合は 404 ページにリダイレクトします。

何らかの理由で、Apache 2.2.27 を実行している FreeBSD では動作しますが、現時点で Apache 2.2.15 を実行している CentOS では動作しません。これは非常に単純な書き換えルールで、どちらのバージョンの Apache でも問題なく動作するはずですが、ファイルにアクセスしようとすると Apache が 404 をスローし続けます。何か見落としているのでしょうか? 明らかに、表示されているコードには SSL 構成と特定のオプションがありませんが、これらは ssl.conf で reqrites が表示される順序です。

前もって感謝します

更新: 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

関連情報