Page tree
Skip to end of metadata
Go to start of metadata

 

Description

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

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/Mime/list_redirects

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.
 
// List redirects
$mime_list_redirects = $cpanel->uapi(
    'Mime', 'list_redirects'
);

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.
 
# List redirects
my $mime_list_redirects = $cpliveapi->uapi(
    'Mime', 'list_redirects',
);

Note:

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

 cPanel Template Toolkit
<!--   List MIME types in Apache -->
[% data = execute( 'Mime', 'list_redirects', ); %]
[% FOREACH q = data %]
     <p>
         [% q %]
     </p>
[% END %]

Note:

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

 Command Line
uapi --user=username Mime list_redirects

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. 
  • We introduced this functionality in cPanel & WHM version 56.

 Output (JSON)
{{
  "messages": null,
  "errors": null,
  "status": 1,
  "data": [
    {
      "source": "/example",
      "targeturl": "http://redirect.example.com/",
      "destination": "http://redirect.example.com/",
      "displaydomain": "ALL",
      "displaysourceurl": "/marceau.html",
      "kind": "rewrite",
      "domain": ".*",
      "wildcard_text": "",
      "opts": "L",
      "docroot": "/home/example/public_html",
      "matchwww": 1,
      "wildcard": 0,
      "urldomain": "example.com",
      "sourceurl": "/marceau.html",
      "matchwww_text": "checked",
      "type": "permanent"
    }
  ],
  "metadata": {
    "transformed": 1
  }
}


Note:

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

Parameters

ParameterTypeDescriptionPossible valuesExample
regexstring

A Perl Compatible Regular Expression (PCRE) that filters the results. The system matches the PCRE to both the email address's username and domain.

A valid regex expression./^[a-z0-9_-]{6,18}$/

Returns

ReturnTypeDescriptionPossible valuesExample
urldomainstringThe domain to redirect.A valid domain.example.com
sourcestringThe file within the domain to test.A valid filename and path, relative to the home directory.
/marceau.html
targeturlstringThe redirect's destination.A valid URL.
http://redirect.example.com/
destinationstringThe redirect's destination.A valid URL.
http://redirect.example.com/
sourceurlstringThe file within the domain to test.A valid filename and path, relative to the home directory.
/marceau.html
displaydomainstringThe domain to redirect.

ALL is the only possible value.

ALL
displaysourceurlstringThe file within the domain to test.A valid filename and path, relative to the home directory.
/marceau.html
wildcard_textstringWhether the Wild Card Redirect option is active.
  • checked — Wild Card Redirection is active.
checked
matchwww_textstringWhether Redirect With www. option is active.
  • checked — Wild Card Redirection is active.
checked
domainstringThe domain to redirect.A valid domain name.example.com
kindstringThe kind of redirect.

rewrite is the only possible value.

rewrite
docrootstringThe source domain's document root.A valid absolute file path./home/example/public_html
matchwwwBooleanWhether the redirect matches www. subdomains.
  • 1 — Matches.
  • 0 — Does not match.
1
typestringWhether the redirect is permanent or temporary.
  • permanent
  • temporary
permanent
wildcardBooleanWhether the wildcard subdomains match.
  • 1 — Matches.
  • 0 — Does not match.
1