cPanel/Mime
cPanel module

Mime

14 functions, invoked through the cpanel_uapi tool.

scope cpanel:uapi
Call any function with cpanel_uapi(service_id, module="Mime", function, params). Live availability depends on the cPanel features JetHost has enabled on your account — call list_cpanel_operations to see what is active.

add_handler GET#

Add web server MIME type handler

This function creates an Apache MIME type handler for a file extension.

Important:

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

extensionstringRequired
The file extension.
handlerstringRequired
The Apache MIME handler.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

add_mime GET#

Add MIME type to web server

This function adds a MIME type to Apache.

Important:

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

extensionstringRequired
The file extension.
typestringRequired
The MIME type.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

add_redirect GET#

Add redirect to domain

This function adds a redirect to a domain.

Important:

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

domainstringRequired
The domain from which to redirect.
redirectstringRequired
The URL to which to redirect.
redirect_wildcardintegerOptional
Whether to redirect all files within a directory to the same filename within the destination directory. 1 - Redirect all files within the directory. 0 - Do not redirect all files within the directory.
redirect_wwwintegerOptional
Whether to redirect domains with or without www. 2 - Redirect with www. 1 - Redirect without www. * 0 - Redirect with and without www.
srcstringOptional
A specific page from which to redirect.
typestringOptional
Whether the redirect is temporary. permanent temp

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

delete_handler GET#

Remove web server MIME type handler

This function deletes an Apache MIME type handler.

Important:

When you disable the WebServer role, the system disables this function.

extensionstringRequired
The file extension.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

delete_mime GET#

Remove MIME type from web server

This function removes a MIME type from Apache.

Important:

When you disable the WebServer role, the system disables this function.

typestringRequired
The MIME type.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

delete_redirect GET#

Remove redirect from domain

This function removes a redirect from a domain.

Important:

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

domainstringRequired
The domain name.
argsstringOptional
An argument string that contains the arguments of a Redirect or RedirectMatch directives.
docrootstringOptional
The absolute file path to the document root containing the .htaccess file to change. If you don't pass this parameter, the system looks up the document root from the domain parameter's value.
srcstringOptional
The specific page that redirects visitors.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

Payload varies by call.

get_redirect GET#

Return redirect URL for domain

This function retrieves a redirection URL for a domain.

domainstringRequired
The domain's name.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

redirection_enabledinteger
Whether the domain redirects to another URL. 1 - Redirects. 0 - Doesn't redirect.
One of: 0 1
urlstring
The URL to which to the domain redirects.

list_handlers GET#

Return web server's MIME handlers

This function lists all of Apache's MIME handlers.

Important:

When you disable the WebServer role, the system disables this function.

typestringRequired
Whether to retrieve system or user handlers.

Response — normalized as { ok, data, errors[], warnings[] }; data is an array of:

extensionstring
The handler's extension. A valid file extension.
handlerstring
The handler's name. A valid string.
originstring
The handler's owner. - system - user

list_mime GET#

Return web server's MIME types

This function lists all of Apache's MIME types.

Note:

This function does not list PHP versions with MIME types when the user or domain enables PHP-FPM. The system displays only custom MIME types.

Important:

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

typestringRequired
The MIME types to list. system — List the Apache system MIME types. user — List the Apache user MIME types.

Response — normalized as { ok, data, errors[], warnings[] }; data is an array of:

extensionstring
The file extension.
originstring
The handler's owner. system user
One of: system user
typestring
The MIME type.

list_redirects GET#

Return .htaccess files' redirects

This function lists the redirects in an account's .htaccess files.

Important:

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

destinationstringOptional
The string with which to filter results. Note: This will only return results that match the destination parameter exactly.
regexstringOptional
A Perl regular expression that filters the results. The system matches the regular expression to the sourceurl return value.

Response — normalized as { ok, data, errors[], warnings[] }; data is an array of:

destinationstring
The redirect's destination URL.
displaydomainstring
The domain to redirect. * ALL is the only possible value.
One of: ALL
displaysourceurlstring
The path to the file within the domain to test, relative to the home directory.
docrootstring
The absolute file path to the source domain's document root.
domainstring
The domain to redirect.
kindstring
The kind of redirect. rewrite — The request sent a redirect to another path on the server. redirect — The request sent a redirect for the URL. * redirectmatch — The request sent a redirect based on a regular expression match of the URL.
One of: rewrite redirect redirectmatch
matchwwwinteger
Whether the redirect matches www. subdomains. 1 — Matches. 0 — Does not match.
One of: 1 0
matchwww_textstring
Whether the Redirect with or without www. option is active. * checked — The Redirect with or without www. option is active.
One of: checked
optsstring
The options that the function passes to Apache as part of the Rewrite rule.
sourcestring
The path to the file within the domain to test, relative to the home directory.
sourceurlstring
The path to the file within the domain to test, relative to the home directory.
statuscodestring
The HTTP Status Code of the request
targeturlstring
The redirect's destination URL.
typestring
Whether the redirect is permanent or temporary. permanent — The redirect is permanent. temporary — The redirect is temporary.
One of: permanent temporary
urldomainstring
The domain to redirect.
wildcardinteger
Whether the wildcard subdomains match. 1 — Matches. 0 — Does not match.
One of: 1 0
wildcard_textstring
Whether the Wild Card Redirect option is active. * checked — The Wild Card Redirect option is active.
One of: checked

redirect_info GET#

Return redirect information

This function retrieves redirect information for a URL or All Public Domains .

Important:

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

domainstringRequired
The domain for which to retrieve redirector information.
urlstringRequired
The URL for which to retrieve redirector information.

Response — normalized as { ok, data, errors[], warnings[] }; data contains:

domainstring
The redirect's domain, or All Public Domains . A valid domain. All Public Domains
urlstring
The redirect's URL.