I have a Plesk VPS with several hundred domains. Most have the same IP.
If a user goes to an invalid sub domain, they are always redirected to the 1st domain I setup. How can I force invalid subdomain requests such as xyz.domain.com to redirect to www.domain.com either via htaccess or DNS ?
2
Answers
Below is the htaccess rule you should place in htaccess file for you domain “domain.com
It’s can be done via .htaccess because invalid subdomains are not hit into valid virtual host.
Think it can be done via wildcard CNAME DNS record via Tools&Settings > DNS template (but please test it first on some test site)
(Pay attention that this operation may be not applied for domains with customized DNS records)
(Pay attention that if you tried to force applying DNS template than all domains DNS customization may be lost(I’ve not remember exactly this bihaviour))
In case you can’t use DNS template you always can add new DNS records to every domain automatically via command
/usr/local/psa/bin/dns