Try adding this to an appropriate place in your .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^answers.mydomain.com$ [NC]
RewriteRule ^ http://mydomain.com/suberror [L,R]
As long as the requested host is answers.mydomain.com
, the rule will be applied. With the regex match set to ^
, any URI will match and the target will be redirected to http://mydomain.com/suberror
If you want only specific URI requests to be redirected to /suberror, you can tweak the ^
to something appropriate.
EDIT:
For all subdomains (including www.mydomain.com):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+).mydomain.com$ [NC]
RewriteRule ^ http://mydomain.com/suberror [L,R]
To exclude www.mydomain.com, add this line before the RewriteRule:
RewriteCond %{HTTP_HOST} !^www.mydomain.com$ [NC]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…