Description
This function adds a redirect to a domain.
Examples
cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/Mime/add_redirect?domain%3D.*%26src%3Dhttp%3A%2F%2Fexample.com%2Fspecific-page%26redirect%3Dhttp%3A%2F%2Fexample2.com%26redirect_wildcard%3D1%26redirect_www%3D0%26type%3Dpermanent
LiveAPI PHP Class
$cpanel
=
new
CPANEL();
$mime_add_redirect
=
$cpanel
->uapi(
'Mime'
,
'add_redirect'
,
array
(
'domain'
=>
'example.com'
,
'src'
=>
'http://example.com/specific-page'
,
'redirect'
=>
'http://example.com/'
,
'type'
=>
'permanent'
,
'redirect_wildcard'
=>
'1'
,
'redirect_www'
=>
'0'
,
)
);
LiveAPI Perl Module
my
$cpliveapi
= Cpanel::LiveAPI->new();
my
$mime_add_redirect
=
$cpliveapi
->uapi(
'Mime'
,
'add_redirect'
,
{
'domain'
=>
'example.com'
,
'src'
=>
'http://example.com/specific-page'
,
'redirect'
=>
'http://example.com/'
,
'type'
=>
'permanent'
,
'redirect_wildcard'
=>
'1'
,
'redirect_www'
=>
'0'
,
}
);
cPanel Template Toolkit
[% data = execute( 'Mime', 'add_redirect', {'domain' => 'example.com', 'src' => 'http://example.com/specific-page','redirect' => 'http://example.com/', 'type' => 'permanent','redirect_wildcard' => '1','redirect_www' => '0',} ); %]
Command Line
uapi --user=username Mime add_redirect domain=example.com src=http%3A%5C%2F%5C%2Fexample.com%5C%2Fspecified-page redirect=http%3A%2F%2Fexample.com%2F type=permanent redirect_wildcard=1 redirect_www=0
|
Output (JSON)
{
"messages": null,
"errors": null,
"status": 1,
"data": null
}
Parameters
Parameter
|
Type
|
Description
|
Possible values
|
Example
|
domain
|
string
|
Required
The domain from which to redirect.
|
A valid domain.
|
example.com
|
src
|
string
|
A specific page from which to redirect.
|
A valid URL.
|
http://example.com/specific-page
|
redirect
|
string
|
Required
The URL to which to redirect.
|
A valid URL.
|
http://example.com/
|
type
|
string
|
Required
Whether the redirect is temporary.
|
|
permanent
|
redirect_wildcard
|
Boolean
|
Whether to include all of the domain's subdomains.
This value defaults to 0.
|
- 1 — Include the domain's subdomains.
- 0 — Do not include the domain's subdomains.
|
1
|
redirect_www
|
integer
|
Whether to redirect domains with or without www.
This value defaults to 0.
|
- 2 — Redirect with www.
- 1 — Redirect without www.
- 0 — Redirect with and without www.
|
0
|
Returns
This function only returns metadata.