具体的には、Redirect
というディレクティブではなく、RewriteCond/RewriteRule
を使用する必要があります。 foo.mydomain.com
には(!
)の否定一致を行い、書き換えを実行します。あなたは、あなただけの代わりに$1
を経由して、全体のURIを追加するのルートにリダイレクトしたい場合は、同じRewriteCond
を使用するか、またはグループ(foo|other1|other2)
RewriteEngine On
# Redirect anything except foo.example.com, bar.example.com
RewriteCond %{HTTP_HOST} !^(foo|bar)\.example\.com$ [NC]
# Redirect to www.example.com, preserving the URI
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=302]
で複数のサブドメインにマッチし、ちょうど行うことがあります。
# Match and redirect everything to the root of www.example.com
RewriteRule ^. http://www.example.com/ [L,R=302]
感謝をとても! :) – Brett
私は 'RewriteRule'を編集して動作させる必要がありました:' RewriteRule ^。* http://www.example.com/ [L、R = 302] ' – Brett