1

Apache mod_rewrite を使用して、QueryString の値を置き換える必要があります。多くの値を 1 つの新しい値に置き換える必要があります ({oldValueA1, oldValueA2} => newValueA; {oldValueB1, oldValueB2} => newValueB)。このパラメーターは、query_string 内で何度も表示されます。パラメータ値の順序はランダムです。リダイレクトされた query_string に値が 2 回含まれていても、それは問題ではありません。request_uri は可変ですが、リダイレクト中に変更しないでください。

下記は用例です。最初の行には元の URL が含まれ、2 番目の行には新しい URL が含まれます。

localhost/mag/cat/?myParameter=oldValueA1&myParameter=oldValueB1
localhost/mag/cat/?myParameter=newValueA&myParameter=newValueB

localhost/mag/?myParameter=oldValueA2
localhost/mag/?myParameter=newValueA

localhost/dig/cat/?myParameter=oldValueB1&myParameter=oldValueA2
localhost/dig/cat/?myParameter=newValueB&myParameter=newValueA

localhost/dig/?myParameter=oldValueB2&oldValueB3
localhost/dig/?myParameter=newValueB&newValueB

いくつかの条件でいくつかの RewriteRules を試しましたが、この問題の解決策が見つかりません。誰かアイデアはありますか?

どうも!:)

4

1 に答える 1

2

問題の解決策を見つけました。多分それは他の誰かにも役立つでしょう。ここにあります:

RewriteCond %{QUERY_STRING} ^(.*[&?]|)myParameter=(oldValueA1|oldValueA2)([&?].*|)$
RewriteRule ^(.*)$ $1?%1myParameter=newValueA [R=301,NC,L]
RewriteCond %{QUERY_STRING} ^(.*[&?]|)myParameter=(oldValueB1|oldValueB2)([&?].*|)$
RewriteRule ^(.*)$ $1?%1myParameter=newValueB [R=301,NC,L]
于 2013-11-11T21:44:14.100 に答える