I have Plesk installed on my web server. 1and1 helpfully redirect all subdomains (wildcard) at a the server when you register the domain. This means that you can add subdomains straight to Plesk without having to register them through the 1and1 control panel.

All non-existent subdomain URLs are by default routed to the primary domain by Plesk. You can set this up by going to Server > IP Addresses in Plesk. In the far-right “Hosting” column of your IP list, click on the number – and you should see a list of your domains. Pick your primary and click “Set As Default”.

The issue this brings is this:

1) My primary domain is douglasradburn.co.uk, and I also have the domain website-preview.co.uk on the same server.

2) If a request is made for idontexist.douglasradburn.co.uk, which doesn’t exist, then…

3) The server returns the content from my primary domain, douglasradburn.co.uk, with the address bar still showing idontexist.douglasradburn.co.uk

Whether or not this default functionality becomes a problem depends on your situation. For me, this functionality means that anyone linking to idontexist.douglasradburn.co.uk (for whatever reason) could create duplicate content issues within SERPs.

What I would prefer is for Plesk to 301 to the default domain.

I thought this would be quite easy at first – but Plesk has no option for this.

After a lot of head scratching and, in the end, asking around the office, the solution was fairly simple.

Using the .htaccess file, I redirect any request that isn’t made to the primary domain, to the primary domain.

This could be extended to redirect to a specific page, or with different headers – for example a 404 explaining that the subdomain doesn’t exist.

Requests to existing subdomains and domains will, of course, hit their own vhost.conf and .htaccess files – meaning this redirect will only affect Plesk’s default primary domain action.

One thing this doesn’t fix is a request for something.website-preview.co.uk being redirected to www.douglasradburn.co.uk instead of the root domain (website-preview.co.uk).

Image Credit: Ian Sane