1

基本的に、トラフィックを送信するサーバーを決定するために、クエリ文字列パラメーターの最初の文字を使用して(この質問の範囲外の理由で)2つのサーバーの負荷を分散しようとしています。

これまでの説明として、「user」をパラメータとして、サーバーが2台あると仮定します。AとMの間の文字で始まる名前のユーザーにサービスを提供するためのサーバー1と、NからZの間の2番目のサーバー。

たとえば、

https://www.example.com/service/user = paul

に行きます

https://*am.internal。* example.com / service /?user = paul

そして、

https://www.example.com/service/user = orla

に行きます

https://*nz.internal。* example.com / service /?user = orla

これまでのところ、私はこのようなものを持っています:

RewriteEngine On
RewriteCond %{Query_String} ^[\?\&]user=[n-z].*
RewriteRule ^(.*) https://n-z. internal .example.com/service/$1 [P]

RewriteRule ^(.*) https://a-m.internal.example.com/service/$1 [P,L]

まず、nzの場合は書き直し、ルールにURL($ 1)を追加します。nzと一致しない場合は、デフォルトでamに送信します。

私はmod_rewriteを初めて使用しますが、希望どおりに動作する組み合わせや順列を見つけることができないようです。

なぜ私が期待した結果が得られないのか誰かが説明できますか?ありがとう!

4

1 に答える 1

0

これを試して :

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteCond %{QUERY_STRING} ^(.*\&)?user=[a-m]
RewriteRule ^(.*)$ https://a-m.internal.example.com/$1 [QSA,P]

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteCond %{QUERY_STRING} ^(.*\&)?user=[n-z]
RewriteRule ^(.*)$ https://n-z.internal.example.com/$1 [QSA,P]
于 2012-08-29T14:09:05.890 に答える