1

パラメータ付きの特定の URL を別のドメインにリダイレクトしたい

http://domain.tld/buy/?w=X1234からhttp://anotherdomain.tld/product.php?id=X1234 へ

ここに私のhtaccess

RewriteCond %{REQUEST_URI} !^/*buy/(.*)$ [NC]
RewriteRule ^/*buy/?w=([a-zA-Z0-9]+)$ http://anotherdomain.tld/product.php?id=$1 [NC,L,R=301]

しかし、機能していません。おそらく問題は param ?w= です

ありがとうございました

更新: How to REGEX and .htaccess rewrite url を読んだ後、クエリ文字列を使用して問題を解決します

RewriteCond %{QUERY_STRING} ^w=([a-zA-Z0-9]+)$
RewriteRule ^/*buy/$ http://anotherdomain.tld/product.php?id=%1 [NC,L,R=301]

スタックオーバーフローと皆さん、ありがとう!ここから正規表現を理解し始めます^_^

4

1 に答える 1

0

そうです、あなたのパラメータは取得されませんが、渡すことができます。

何かのようなもの;

RewriteRule ^buy/([a-zA-Z0-9]+)$ http://anotherdomain.tld/product.php?id=$1 [NC,L,R=301]

元の URL の場所。/購入/X1234

于 2013-05-19T00:53:44.113 に答える