You can find our user documentation at docs.cpanel.net.

Check out our new API beta site!

Child pages
  • UAPI Functions - Mime::list_redirects
Skip to end of metadata
Go to start of metadata

Description

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

Important:

In cPanel & WHM version 76 and later, when you disable the Web Server role, the system disables this function.

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.

 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. 
  • 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,
  "data": [
    {
      "destination":"http://redirect.example.com/",
	  "displaydomain":"ALL",
	  "displaysourceurl":"/marceau.html",
	  "docroot":"/home/example/public_html",
	  "domain":"example.com",
	  "kind":"rewrite",
	  "matchwww":1,
	  "matchwww_text":"checked",
	  "opts":"L",
	  "source":"/marceau.html",
	  "sourceurl":"/marceau.html",
	  "statuscode":"301",
	  "targeturl":"http://redirect.example.com/",
	  "type":"permanent",
	  "urldomain":"example.com",
	  "wildcard":1,
	  "wildcard_text":"checked"
     }
  ],
  "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 the sourceurl return value.

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

Returns

ReturnTypeDescriptionPossible valuesExample
destinationstringThe redirect's destination.A valid URL.
http://redirect.example.com/
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
docrootstringThe source domain's document root.A valid absolute file path./home/example/public_html
domainstringThe domain to redirect.A valid domain name.example.com
kindstringThe 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
rewrite
matchwwwBooleanWhether the redirect matches www. subdomains.
  • 1 — Matches.
  • 0 — Does not match.
1
matchwww_textstringWhether Redirect With www. option is active.

checked — Wild Card Redirection is active.

checked
optsstringThe options that the function passes to Apache as part of the Rewrite Rule.A valid Rewrite rule.L
sourcestringThe file within the domain to test.A valid filename and path, relative to the home directory.
/marceau.html
sourceurlstringThe file within the domain to test.A valid filename and path, relative to the home directory.
/marceau.html
statuscodestringThe HTTP Status Code of the request.A valid HTTP Status Code.301
targeturlstringThe redirect's destination.A valid URL.
http://redirect.example.com/
typestringWhether the redirect is permanent or temporary.
  • permanent
  • temporary
permanent
urldomainstringThe domain to redirect.A valid domain.example.com
wildcardBooleanWhether the wildcard subdomains match.
  • 1 — Matches.
  • 0 — Does not match.
1
wildcard_textstringWhether the Wild Card Redirect option is active.

checked — Wild Card Redirection is active.

checked