Use a RewriteCond
to match domains other than mydomain.com
and 301 redirect them:
RewriteEngine On
# If the domain (any domain) is not exactly mydomain.com...
RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC]
RewriteRule (.*) http://mydomain.com/$1 [L,R=301,QSA]
You can also look more specifically for subdomains of mydomain.com
. The one above would match any other domain.
# Match only subdomains of mydomain.com
RewriteCond %{HTTP_HOST} ^(.+).mydomain.com$ [NC]
RewriteRule (.*) http://mydomain.com/$1 [L,R=301,QSA]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…