Create a subdomain in Plesk with www prefix
Subdomains set up in Plesk VPS enviroments are usually only available without the www prefix on the domain name. This means that the subdomain subdomain.example.com will work where www.subdomain.example.com returns a "Server not found" error.
Technically a domain name with and without the prefix is classed as two separate domains, and could therefore house two different websites. Generally it's best if your website is available with and without the www prefix. There are SEO issues with this which I will cover later.
If you want your domain to be available with and without the www prefix you need to do the following:
In the Plesk VPS control panel choose the domain on which you wish to make a subdomain...e.g. example.com. Under the Hosting section click 'Subdomains' and click 'Add New Subdomain'.
On the 'Create a Subdomain' page, type the name you want to give the subdomain...e.g. subdomain.example.com (without www).
Choose which services you require...e.g. php support.
Click OK. The Subdomain is now created. Unfortunatle the zone doesn't automatically get updated to the DNS...which has to be manually configured.
Under the main Plesk control panel click 'All My Domains' and click the domain you just set up the subdomain under. In our case...exapmle.com. Click the tab 'DNS Zone'. Click on 'New Record' and create a new A record with name subdomain.example.com. As value you need to enter the IP Address of the domain.
Create a second A record the same as above but this time with the www prefix....e.g. www.subdomain.example.com
Now...in the File Manager navigate to var > www > vhosts > example.com > subdomains > subdomain (the name you gave it) > conf. If there is no vhost.conf file within the conf folder then create or upload one. In the vhost.conf file write:-
ServerAlias www.subdomain.example.com
Now login with your SSH client (I use the Mac OS X Terminal) and run this command to apply changes.
/usr/local/psa/admin/sbin/websrvmng -v -a
That should be it. It may take a while for the DNS to propagate before the website is available.
On a Search Engine Optimisation level (SEO), it is not advisable to have both prefixed and non prefixed domains pointing to the same website. Search engines class this as identical content which can lead to poor search engine results. One way around this is to use the Apache Mod_Rewrite method of redirecting one domain to the other...effectively combining both domain names.
In our example we are redirecting www.subdomain.example.com to subdomain.example.com
In the .htaccess file (found in the httpdocs folder) write the following code.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.subdomain.example\.com$ [NC]
RewriteRule ^(.*)$ http://subdomain.example.com/$1 [L,R=301]
Now everyone who visits your site using www.subdomain.example.com will get instantly redirected to subdomain.example.com and google won't punish you for having duplicate content.

Add new comment