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):

  • Alias status
  • Alias preferences

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:

Note: The interactive schema navigator for all request packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_input.svg.

  • The status node is optional. It specifies the status of a site alias. For more information, see the Site Alias Settings section. Data type: string. Allowed values: ok | error.
  • The pref node is optional. It specifies preferences of a site alias. For more information, see the Site Alias Settings section. Data type: none.
  • The manage-dns node is optional. It defines if you can manage DNS zone for the site alias.
  • The site-id node is required. It specifies the id of the primary site. Data type: integer.
  • The name node is required. It specifies the name of the primary site. Data type: string (Unicode).
  • The ascii-name node is optional. It specifies the name of the primary site. Data type: string (ASCII).

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:

Note: The interactive schema navigator for all response packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_output.svg.

  • The result node is required. It wraps the response retrieved from the server. Data type: AliasResultType (domainalias_output.xsd).
  • The status node is required. It specifies the execution status of the create operation. Data type: string. Allowed values: ok | error.
  • The errcode node is optional. It is used to return the error code when the create operation fails. Data type: unsignedInt.
  • The errtext node is optional. Can be used to return the error message if the create operation fails. Data type: string.
  • The id node is optional. It returns the ID of the site alias; it is required if the create operation has succeeded. Returns the unique identifier of the site alias just added to Plesk. Data type: integer.
 

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:

  • DisabledAlias is disabled.
  • EnabledWebOnlyAlias is enabled and has only web content redirection.
<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>
 

Leave your feedback on this topic here

If you have questions or need support, please visit the Plesk forum or contact your hosting provider.
The comments below are for feedback on the documentation only. No timely answers or help will be provided.