Plesk subdomains with www

Plesk does not allow adding www or other prefixes to the subdomains as it allows with domains. By default the Plesk Control Panel will allow you to add subdomains without any prefix. From a strictly technical perspective, this is wrong as all the web pages should be indicated by a www prefix in front of them.

(Assuming you already have created a subdomain)
In order to add the www prefix for your domain in Plesk, locate on the server the vhost configuration file for the domain:

On RedHat distros (RHEL, CentOS, Fedora) it should look like:
/var/www/vhosts/domain.ext/subdomains/subdomain/conf/vhost.conf

on SuSE distros (SLES, OpenSuse)
/srv/vhosts/domain.ext/subdomains/subdomain/conf/vhost.conf

You will need to replace domain.ext and subdomain with your domain-name and subdomain-name values.

vi /var/www/vhosts/domain.ext/subdomains/subdomain/conf/vhost.conf

type ‘i‘ for interactive mode and enter

ServerAlias www.subdomain.domain.ext

press Esc (Escape) to exit interactive mode of vi, type :x! to save the file (if the file was new, it would be created)

Once the file is created you have to ask Plesk reconfigure Apache to recognize the changes.

/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=domain.ext
/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=subdomain.domain.ext

If the above command returns an error like “no such file or directory”, you need to locate the correct websrvmng tool.

For more read this Knowledgebase article: <a href="http://kb.parallels.com/en/952" target="_blank">http://kb.parallels.com/en/952</a>

Here we have finished configuring apache. One more change in the DNS is neccessary. Open the Plesk Control Panel and navigate to the DNS Section of your main domain (domain.ext). Add a new record:

*.subdomain.domain.ext CNAME subdomain.domain.ext

Now the subdomain will be accessible even through http://www.subdomain.domain.ext

Leave a Reply