Creating Site Aliases

In this chapter:

Only Plesk Administrator can create site aliases via API RPC. To create a site alias, it is enough to specify the site ID and the site name.

You can also specify alias settings when creating a site alias (all of them are optional):

You can specify alias settings during or after creation of an alias. Alias settings can be set using the set operation. To get information on which site alias settings can be set on a particular server, use the get-supported-services operation.

 

Request Packet Structure

A request XML packet creating a new site alias in Plesk database includes the create operation node:

<packet>
<site-alias>
   <create>
   ...
   </create>
</site-alias>
</packet>

 

The create node is presented by the AliasInfoType type (plesk_domainalias.xsd). Its graphical representation is as follows:

Important: When creating request packets, put nodes and elements in the order they follow in the packet structure.

 

Response Packet Structure

The create node of the output XML packet is structured as follows:

 

Samples

Creating a single site alias

To create a site alias, specify the ID of the primary site (the alias will be linked to) and name of the alias.

<packet>
<site-alias>
<create>
   <site-id>12</site-id>
   <name>myalias.com</name>
</create>
</site-alias>
</packet>

Response:

<packet>
<site-alias>
<create>
   <result>
      <status>ok</status>
      <id>34</id>
   </result>
</create>
</site-alias>
</packet>
Creating multiple site aliases

To create two site aliases with a single packet, include two different create operations:

<packet>
<site-alias>
<create>
   <site-id>12</site-id>
   <name>MyAlias.com</name>
</create>
<create>
   <site-id>12</site-id>
   <name>MySecondAlias.com</name>
</create>
</site-alias>
</packet>
Alias settings

The following packet creates site aliases to the site with ID 12. The alias settings are as follows:

<packet>
<site-alias>

<create>
      <status>1</status>
   <site-id>12</site-id>
   <name>DisabledAlias.com</name>
</create>

<create>
   <status>0</status>
   <pref>
      <web>1</web>
      <mail>0</mail>
      <tomcat>0</tomcat>
   </pref>
   <site-id>12</site-id>
   <name>EnabledWebOnlyAlias</name>
</create>

</site-alias>
</packet>