0

I am trying to combine a rewrite and a proxy pass and having issues with the rewrite. Here is what I have

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.world.net
RewriteRule %{HTTP_HOST} http://newexample.newworld.net:7802/apex/f?p=208 [R,P]
ProxyPass / http://newexample.newworld.net:7802/

The proxypass is working, but I can't figure out how to get the initial redirect. So if the user puts in example.world.net/apex/f?p=208 it goes to newexample.newworld.net:7802/apex/f?p=208 and masks the url.

However I need to get example.world.net to redirect to example.world.net/apex/f?p=208 if the apex/f?p=208 is not in the url.

4

2 に答える 2

2

リダイレクトとプロキシを同時に行うことはできません。書き換えルールのフラグは[R,P]、「リダイレクト」と「プロキシ」です。ここでどちらかが必要になります。また、ルールの正規表現は%{HTTP_HOST}、URL が文字通り: でない限り、一致することはありませんhttp://example.world.net/%{HTTP_HOST}。次のように変更する必要があります。

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.world.net
RewriteCond %{QUERY_STRING} !(^|&)p=208(&|$)
RewriteRule ^/?$ /apex/f?p=208 [L,QSA,R]

URL アドレス バーに と表示されている場合、これによりブラウザがリダイレクトされhttp://example.world.net/ますhttp://example.world.net/apex/f?p=208。次に、それを取得してプロキシするのはプロキシ次第/apex/f?p=208ですhttp://newexample.newworld.net:7802/

mod_proxy と mod_rewrite が一緒にうまく動作しない可能性があります。これは、両方が同じ URL に適用される可能性があるためです。両方が同時に適用されていることがわかった場合は、ProxyPass行を次のように変更します。

RewriteRule ^/?(.*)% http://newexample.newworld.net:7802/$1 [L,P,QSA]
于 2012-10-16T03:29:56.597 に答える
0

example.world.net をhttp://newexample.newworld.net:7802/apex/f?p=208またはexample.world.net/apex/f?p=208にリダイレクトしますか? 前者を想定していますが、間違っている場合は RewriteRule の URL を後者に変更してください。

しかし、私はこれがそれを行うべきだと思います

RewriteCond %{HTTP_HOST} ^example.world.net$ [NC]
RewriteRule %{HTTP_HOST} http://newexample.newworld.net:7802/apex/f?p=208 [R,L]

ただし、仮想ホストの名前/エイリアスが不明であるため、/

ProxyPass / http://newexample.newworld.net:7802/

すべてを壊すかもしれません。

于 2012-10-16T02:51:45.743 に答える