Child pages
  • UAPI Functions - SSL::toggle_ssl_redirect_for_domains
Skip to end of metadata
Go to start of metadata

Description

This function enables or disables secure redirects (HTTPS) for the cPanel account's domains that you specify.

Important:

To call this function, one of the following conditions must exist:

  • AutoSSL must exist on the domains for which you enable secure redirects.
  • A valid SSL certificate must exist for each domain for which you wish to enable secure redirects.
  • You must own the domains for which you wish to enable secure redirects.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/SSL/toggle_ssl_redirect_for_domains?domains=example.com%2Cexample2.com%2Cexample2.addon.com&state=1


Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Enable HTTPS for the following domains.
$SSL_add_autossl_excluded_domains = $cpanel->uapi(
    'SSL', 'toggle_ssl_redirect_for_domains',
	array(
		 'domains'	=> 	'example.com,example2.com,example2.addon.com',
		 'state'    =>  '1', 
		 )
);


Note:

For more information, read our Guide to the LiveAPI System.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
#  Enable HTTPS for the following domains.
my $SSL_add_autossl_excluded_domains = $cpliveapi->uapi(
    'SSL', 'toggle_ssl_redirect_for_domains'
	{
		'domains'	=>	'example.com,example2.com,example2.addon.com',
		'state'     =>  '1'
	}
);


Note:

For more information, read our Guide to the LiveAPI System.

 cPanel Template Toolkit
<!-- Enable HTTPS for the following domains. -->
[% execute( 'SSL', 'toggle_ssl_redirect_for_domains', { 'domains' => 'example.com,example2.com,example2.addon.com','state' => '1' }); %]


Note:

For more information, read our Guide to Template Toolkit documentation. 

 Command Line
uapi --user=username SSL toggle_ssl_redirect_for_domains domains=example.com,example2.com,example2.addon.com state=1


Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{
    "messages": null,
    "errors": null,
    "status": 1,
    "metadata": {
  
    },
    "data": [
        {
            "domain": [
                "example.com",
                "example2.com",
				"example2.addon.com",
            ],
        },

    ],
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
domainsstring

Required

The domain for which to enable or disable secure redirects.

A valid domain name that the account owns.

Important:

To enable or disable redirects for addon domains, you must pass the addon domain and its subdomain. For example, pass the example2.addon.com domain.


Notes:

  • Separate multiple domains with the comma character (,).
  • For browser-based calls, use a URI-encoded comma (%2C).

example.com,example2.com,example2.addon.com

stateBoolean

Required

Whether to enable or disable redirects for the specified domains.

  • 1 — Enable.
  • 0 — Disable.
1

Returns

ReturnTypeDescriptionPossible valuesExample
domainarrayAn array of domains on which secure redirects were enabled or disabled.A list of domains on the server.

example.com

example2.com