0

途方に暮れています...簡単なことをしようとしていますが、何がうまくいかないのか理解できません...

私は単にドメインへのすべてのリクエストを受け取り、それらをindex.phpにルーティングしようとしています

わかりやすくするために編集: index.php は、フレームワークの一部として、リクエストのディスパッチャとして機能します。

ローカル マシンでは問題なく動作していますが、サーバー (VPS Linux with Plesk) ではさまざまな問題が発生しています...

わかりやすくするために編集: これらのルールは、仮想ホストの vhost.conf 構成ファイルで定義されています。

mod_rewrite は次のとおりです。

<IfModule rewrite_module>
    RewriteEngine On
    RewriteRule ^/.* /index.php
</IfModule>

「www.mydomain.com/home/index」にアクセスしようとしたときの Apache エラー ログは次のとおりです (たとえば)。

[debug] core.c(3072): [client xxx.xxx.xxx.xxx] r->uri = /phppath/cgi_wrapper/phppath/cgi_wrapper/phppath/cgi_wrapper/home/index
[debug] core.c(3078): [client xxx.xxx.xxx.xxx] redirected from r->uri = /phppath/cgi_wrapper/phppath/cgi_wrapper/home/index
[debug] core.c(3078): [client xxx.xxx.xxx.xxx] redirected from r->uri = /phppath/cgi_wrapper/home/index
[debug] core.c(3078): [client xxx.xxx.xxx.xxx] redirected from r->uri = /home/index

トレースからわかるように、/home/index を /phppath/cgi_wrapper/ にリダイレクトしているように見えます。その後、/phppath/cgi_wrapper/phppath/cgi_wrapper/home/index に再度渡されたようです。内部リダイレクトの最大数に達しました。

HTTP 500 がブラウザに送信されます。

さらに編集 - 追加情報。Plesk がファイルを分散させる方法からわかることから、これらは仮想ホストに影響を与える唯一の 2 行です。おそらくそのActionステートメントだと思います... vhost.confで何らかの方法でオーバーライドできますか?

in php-cgi.conf:
ScriptAlias /phppath/ "/var/www/cgi-bin/cgi_wrapper/"
Action php-script /phppath/cgi_wrapper

in php.conf:
AddHandler php5-script .php

さらに編集:動的に生成されたconfファイル内でこれを見つけました(vhostレベルで)。

<Files ~ (\.php)>
    SetHandler None
    AddHandler php-script .php
    Options +ExecCGI
    allow from all
</Files>

何が起こっているかについて何か考えを持っている人はいますか?2日間髪を引っ張っています...よろしくお願いします

4

2 に答える 2

0

髪を引き裂き、歯ぎしりをし、キーボードを 3 台使用した後...なんとか機能するものを見つけました。それはきれいではありませんが、それは仕事をします...誰かがこれについて改善を提供できるなら、してください-私はすべて耳です。または目。いわば。

/phppath/cgi_wrapper/home/indexそのため、Apache ログで繰り返し発生する問題に最初に気付き、 「 /home/indexPHP CGI にパスするべきではないかもしれませんが、パスする必要があるかもしれません」と考えましたindex.php。そこで、Rewrite を次のように変更しました。

<IfModule rewrite_module>
    RewriteEngine On
    RewriteLog /blah/blah/blah/rewrite_log
    RewriteLogLevel 5

    RewriteRule ^.*$ /index.php [PT]
</IfModule>

ドキュメントによると、書き換え結果をハンドラーに渡す PassThrough (PT) フラグを追加しただけです。

これにより、次の apache error_logが得られました。

[debug] core.c(3078): [client xxx.xxx.xxx.xxx] redirected from r->uri = /index.php
[debug] core.c(3078): [client xxx.xxx.xxx.xxx] redirected from r->uri = /index.php
[debug] core.c(3078): [client xxx.xxx.xxx.xxx] redirected from r->uri = /index.php

これは改善と考えましたが、それでも機能しませんでした。

それで、キラキラした新しいrewrite_logに行って、これが私を照らしてくれるかどうかを確認しました。私が見た:

xxx.xxx.xxx.xxx - - [28/Aug/2012:15:38:05 +0400] [www.mydomain.com/sid#7f3c39001360][rid#7f3c390bbc88/initial] (2) rewrite '/' -> '/index.php'
xxx.xxx.xxx.xxx - - [28/Aug/2012:15:38:05 +0400] [www.mydomain.com/sid#7f3c39001360][rid#7f3c390bbc88/initial] (2) forcing '/index.php' to get passed through to next API URI-to-filename handler
xxx.xxx.xxx.xxx - - [28/Aug/2012:15:38:05 +0400] [www.mydomain.com/sid#7f3c39001360][rid#7f3c390c2710/initial/redir#1] (2) init rewrite engine with requested uri /phppath/cgi_wrapper/index.php
xxx.xxx.xxx.xxx - - [28/Aug/2012:15:38:05 +0400] [www.mydomain.com/sid#7f3c39001360][rid#7f3c390c2710/initial/redir#1] (3) applying pattern '^/(.*)$' to uri '/phppath/cgi_wrapper/index.php'

したがって、このことから、私は同じ問題を抱えていると推測し/phppath/cgi_wrapper/index.phpました。現在、書き換えエンジンに再度渡されて書き換えられ、これが再び出てきて、/index.php渡されて戻ってきました。

ということで条件を追加。(これは私には醜いように見えるビットです。もっと良い方法があると確信しています):

<IfModule rewrite_module>
    RewriteEngine On
    RewriteLog /blah/blah/blah/rewrite_log
    RewriteLogLevel 5

    RewriteCond ${REQUEST_URI} !^/phppath
    RewriteRule ^.*$ /index.php [PT]
</IfModule>   

その RewriteCond は基本的に言っています: リクエストが で始まらない場合は、次のルールを適用します/phppath

以上です。今は機能しています。すべてのリクエストは、必要に応じて index.php によって処理されます。

于 2012-08-28T13:07:04.740 に答える