Update server's primary virtual host

This function sets the primary domain hosted on an IP address and web server port. The primary domain refers to the virtual host that the server returns when a visitor directly accesses the IP address.

For example, if both example1.com and example2.com are name-based virtual hosts on IP address 192.168.0.1, the primary virtual host appears when the visitor accesses the http://192.168.0.1/ location.

Important:

When you disable the Web Server role, the system disables this function.

SecurityBasicAuth
Request
query Parameters
servername
required
string <domain>

The ServerName value in Apache's VirtualHost section to set as primary for the IP address and port type.

Example: servername=hostname.example.com
type
string
Default: "std"

The type of virtual host to set as primary.

  • std — Set the primary domain for the HTTP port. Typically, port 80.
  • ssl — Set the primary domain for the HTTPS port. Typically, port 443.
Enum: "std" "ssl"
Example: type=std
Responses
200

HTTP Request was successful.

Response Schema: application/json
object
get/set_primary_servername
Request samples
whmapi1 --output=jsonpretty \
  set_primary_servername \
  servername='hostname.example.com'
Response samples
application/json
{
  • "metadata": {
    • "command": "set_primary_servername",
    • "reason": "OK",
    • "result": 1,
    • "version": 1
    }
}