0

ドメイン名の一部を正規表現と一致させる必要があり、一致した部分がファイル名の一部である別のドメインにリダイレクトします。

this-is.com の htaccess の例:

this-is-a-test.com redirects to this-is.com/test.htm
this-is-a-fish.com redirects to this-is.com/fish.htm
this-is-a-duck.com redirect to this-is.com/duck.htm

これまでのところ、次のことを試しました。

RewriteEngine on
RewriteCond %{HTTP_HOST} ^this-is-a-(.*).com$                                                                                                                                         
RewriteRule (.*) http://this-is.com/test.htm [L]

ただし、RewriteRule はクエリ文字列部分のみを処理し、ホスト部分は処理しないため、これは機能しません。

RewriteRule で RewriteCond の一致した部分を使用するにはどうすればよいですか?

4

1 に答える 1

0

解決しました!

今後の参考のために、RewriteCond Match にはパーセント記号を使用する必要があります。

RewriteCond %{HTTP_HOST} ^this-is-a-(.*).com$
RewriteRule (.*) http://this-is.com/%1.htm [L] 
于 2012-09-13T21:27:09.567 に答える