Howto Create ‘Catch all’ subdomains in Plesk

A ‘catch all’  subdomain allows you to redirect all users who might type in http://subdomain.yourdomain.com  where ‘subdomain’ could be any subdomain which you would like to redirect users from.

Why would you need catch all subdomains

Maybe you have a few subdomains but sometimes your visitors are accessing non-existing subdomains. So the most appropriate solution would be to either redirect them to your main website or at least show them a list of available pages.

Step-by-step configuration in Plesk

  1. Create a subdomain ‘z-WILDCARD’ in Plesk – under the admin section of the right domain.
    Why do we need this name?  Because this entry should be the last entry in the list of subdomains, otherwise this “trick” will not work.
  2. Add special configuration (catchall for all subdomains) to the vhosts.conf file of this subdomain.
    Normally it’s located in /srv/www/vhosts/domain.com/subdomains/z-WILDCARD/conf/vhosts.conf. You have to create it – normally you need the root user to do this. Copy the following content into the file:
    ServerAlias *.domain.com
  3. Apply the new configuration – recreate the Apache configuration. You have to run the tool websrvmng which is a Plesk tool that manages and creates the webserver configuration. Execute the following as root user.
    /usr/local/psa/admin/sbin/websrvmng -u --vhost-name=domain.com
  4. Finally – restart Apache to load the new configuration, also as root.
    service httpd restart

That’s it! Now your users can access non-existing subdomains as e.g. doesnotexists.domain.com and you should see the Plesk page displayed for new pages.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Tags: , ,

2 Responses to “Howto Create ‘Catch all’ subdomains in Plesk”

  1. Ben says:

    Hi,
    First off, thanks for posting a tutorial like that.
    I tried to follow it step by step (I use Plesk 10.2 with Ubuntu) and except for the folder (there was nothing in /srv so I went to /var instead) and the command to restart apache (I used init.d) everything seemed to be as you described it. Well, except for the fact that absolutely nothing happened. Using non-existant subdomains just makes me end up in 404 limbo.
    I’ll be looking elsewhere now – maybe you know a possible reason why I failed and can adapt your tutorial in the future.

    Regards,
    Ben

  2. MichalGow says:

    Aftter adding vhosts.conf with wildcard is to website’s folder redirected even subdomain “webmail”, which is dedicated to webmail on server (and which have been working fine before adding vhosts.conf).

    Solution for Plesk 9 (http://codex.wordpress.org/Configuring_Wildcard_Subdomains_for_multi_site_under_Plesk_Control_Panel) is in renaming files zz001_atmail_vhost.conf & zz001_horde_vhost.conf. But they’re removed from Plesk 10…

    Do you have any hint for Plesk 10?

Leave a Reply