Update: I tested the script in my previous post to generate domains on an alternative server and it worked flawlessly (Not quite sure why, and I need to test further). However, one of the features that are missing from Plesk is to create aliases of domains. Through the Plesk API, you can create a redirect on a domain (HTTP Redirect) or a Frameset for example…

<packet version="">

Although thats not quite what I desired, anyway heres a quick modifcation to the PleskDomainsCommand class. There are a few limitations, the first being that it needs to write to vhost.conf file in “/home/httpd/vhosts/ajohnstone.com/conf/vhost.conf” and that open_basedir allows access to that file.

  class PleskDomainsCommand extends PleskObjectCommand {

    function PleskDomainsCommand($Data=null) { parent::PleskObjectCommand($Data);  }
    function Command() { } //Stub

    function addAliasDomain($AliasedDomain, $ActualDomain) {
      $FileName= '/home/httpd/vhosts/'.$ActualDomain.'/conf/vhost.conf';
      $ServerAlias = 'ServerAlias '.$AliasedDomain."\r\n";

      if (is_writable($FileName)) {
        if (!$Handle = fopen($FileName, 'a'))        trigger_error("Cannot open file: ({$FileName})", E_USER_ERROR);
        if (fwrite($Handle, $ServerAlias) === FALSE) trigger_error("Cannot write to file: ({$FileName})", E_USER_ERROR);
      } else { trigger_error("The file ({$FileName}) is not writable", E_USER_ERROR); }

      $Data = "<packet version=\"{$this->Version}\"><server><get><services_state   /></get></server></packet>";
      //restart server id = web
      $Data = "<packet version=\"{$this->Version}\"><server><get><srv_man><id>web</id><operation>restart</operation></srv_man></get></server></packet>";

  $Domains = new PleskDomainsCommand($Data);
  $Domains->addAliasDomain('alternative.test.ajohnstone.com', 'ajohnstone.com');