Using wildcard subdomains in Plesk

In some situations, you may want to have domain.com as well as *.domain.com point to the same site in Plesk. Plesk will automatically set up hosting for domain.com and www.domain.com within the Apache configuration, but you can direct all subdomains for a particular domain to a certain virtual host fairly easily.

DNS Configuration:

Add a CNAME or A record for *.domain.com which points to domain.com (for a CNAME), or the domain’s IP (for an A record).

vi /var/named/run-root/var/domain.com

Add the following line,

*.domain.com.              IN CNAME        domain.com.

OR

*.domain.com.              IN A           12.34.56.78(A Record IP of the domain)

Restart the DNS service
/etc/init.d/named restart

Apache Configuration:
Edit the /var/www/vhosts/domain.com/conf/vhost.conf or create the vhost.conf if doesn’t exist and add the following line,

ServerAlias *.domain.com

then Run,

/usr/local/psa/admin/bin/websrvmng -av

Add the following line in /var/www/vhosts/domain.com/conf/httpd.include file,(With in 80,443 VirtualHost entries)

Include /var/www/vhosts/domain.com/conf/vhost.conf

Then restart the apache,

/etc/init.d/httpd restart