# cPanel API 2 Functions - Mime::listredirects

Warning:
The cPanel API 2 system is deprecated. We **strongly** recommend that you use [UAPI](https://api.docs.cpanel.net/cpanel/introduction) instead of cPanel API 2.

## Description

This function lists the cPanel account's redirects.

Warning:
We **strongly** recommend that you use the following [UAPI](/cpanel/introduction/) function instead of this function:

- [`Mime::list_redirects`](/openapi/cpanel/operation/list_redirects/)


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

Important:
When you disable the [*Web Server* role](https://docs.cpanel.net/knowledge-base/general-systems-administration/how-to-use-server-profiles/#roles),the system **disables** this function.

## Examples

WHM API (JSON)


```undefined syntaxhighlighter-pre
https://hostname.example.com:2087/cpsess###########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Mime&cpanel_jsonapi_func=listredirects
```

Note:
For more information, read our [Calls from the WHM API](/whm/use-whm-api-to-call-cpanel-api-and-uapi) documentation.

LiveAPI PHP Class


```undefined syntaxhighlighter-pre
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.

// List account redirections
$list_redirects = $cpanel->api2(
    'Mime', 'listredirects'
);
```

Note:
For more information, read our [Guide to the LiveAPI System](/guides/guide-to-the-liveapi-system/#guide-to-the-liveapi-system).

LiveAPI Perl Module


```undefined syntaxhighlighter-pre
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.

# List account redirections
my $list_redirects = $cpliveapi->api2(
    'Mime', 'listredirects',
);
```

Note:
For more information, read our [Guide to the LiveAPI System](/guides/guide-to-the-liveapi-system/#guide-to-the-liveapi-system).

cPanel Tag System (deprecated)

Warnings:
- cPanel tags are **deprecated**. We **strongly** recommend that you **only** use the [LiveAPI](/guides/guide-to-the-liveapi-system) system to call the cPanel APIs. Examples are **only** present in order to help developers move from the old cPanel tag system to our [LiveAPI](/guides/guide-to-the-liveapi-system).
- cPanel API 2 calls that use cPanel tags vary in code syntax and in their output.
- For more information, read our [Deprecated cPanel Tag Usage](/cpanel-api-2/cpanel-api-2-deprecate-cpanel-tag-usage) documentation.


Command Line


```undefined syntaxhighlighter-pre
cpapi2 --user=username Mime listredirects
```

div
Notes:

- You **must** URI-encode values.
- `username` represents your account-level username.
- You **must** run the `--user=username` option.
- For more information and additional output options, read our [Guide to cPanel API 2](/cpanel-api-2/) documentation or run the `cpapi2 --help` command.
- If you run CloudLinux™, you **must** use the full path of the `cpapi2` command:

```undefined syntaxhighlighter-pre
/usr/local/cpanel/bin/cpapi2
```


br
Output (JSON)


```undefined syntaxhighlighter-pre
{
  "cpanelresult": {
    "apiversion": 2,
    "func": "listredirects",
    "data": [
      {
        "source": "\/test2",
        "targeturl": "http://test2.example.com/",
        "destination": "http://test2.example.com/",
        "displaydomain": "ALL",
        "displaysourceurl": "/test2",
        "kind": "rewrite",
        "domain": ".*",
        "wildcard_text": "checked",
        "matchwww": 1,
        "docroot": "/home/example/public_html",
        "opts": "L",
        "wildcard": 1,
        "urldomain": "example.com",
        "sourceurl": "/test2",
        "matchwww_text": "checked",
        "type": "temporary"
      },
      {
        "source": "/test",
        "targeturl": "http://test.example.com/",
        "destination": "http://test.example.com/",
        "displaydomain": "example.com",
        "displaysourceurl": "/test",
        "kind": "rewrite",
        "domain": "example.com",
        "wildcard_text": "",
        "matchwww": 1,
        "docroot": "/home/example/public_html",
        "opts": "L",
        "wildcard": 0,
        "urldomain": "example.com",
        "sourceurl": "/test",
        "matchwww_text": "checked",
        "type": "permanent"
      }
    ],
    "event": {
      "result": 1
    },
    "module": "Mime"
  }
}
```

Note:
Use cPanel's [*API Shell*](https://docs.cpanel.net/cpanel/advanced/api-shell-for-cpanel) interface (*cPanel >> Home >> Advanced >> API Shell*) to directly test cPanel API calls.

## Parameters

This function does not accept parameters.

## Returns

table
thead
tr
th
strong
Parameter
th
strong
Type
th
strong
Description
th
strong
Possible values
th
strong
Example
tbody
tr
td
code
source
td
em
string
td
The part of the URL after the domain to redirect.
td
A path and a document name.
td
code
/index.html
tr
td
code
targeturl
td
em
string
td
The redirection destination.
td
A valid URL.
td
code
http://destination.example.com/
tr
td
code
destination
td
em
string
td
The redirection destination.
td
A valid URL.
td
code
http://destination.example.com/
tr
td
code
displaydomain
td
em
string
td
The domain part of the URL to redirect.
td
A valid domain.
td
code
http://www.example.com/
tr
td
code
displaysourceurl
td
em
string
td
The part of the URL after the domain to redirect.
td
A path and a document name.
td
code
/index.html
tr
td
code
kind
td
em
string
td
The kind of redirection.
td
code
rewrite
 is the only possible value.
td
code
rewrite
tr
td
code
domain
td
em
string
td
The domain to redirect.
td
A valid domain
td
code
example.com
tr
td
code
wildcard_text
td
em
string
td
Whether the wildcard checkbox is selected.
td
ul
li
code
checked
 — A wildcard redirection.
li
code
unchecked
 — 
strong
Not
 a wildcard redirection.
td
code
checked
tr
td
code
matchwww
td
em
Boolean
td
Whether the redirection handles the www. subdomain in addition to the domain.
td
ul
li
code
1
 — Redirect the www. subdomain.
li
code
0
 — Do 
strong
not
 redirect the 
code
www
. subdomain.
td
code
1
tr
td
code
docroot
td
em
string
td
The document root for the source domain.
td
A valid path.
td
code
/home/example/public_html
tr
td
code
opts
td
em
string
td
The options that the function passes to Apache as part of the Rewrite Rule.
td
A valid 
a
Rewrite rule
.
td
code
L
tr
td
code
wildcard
td
em
Boolean
td
Whether to redirect all files within a directory to the same filename in the redirected directory.
td
ul
li
code
1
 — A wildcard redirection.
li
code
0
 — 
strong
Not
 a wildcard redirection.
td
code
1
tr
td
code
urldomain
td
em
string
td
The domain to redirect.
td
A valid domain.
td
code
example.com
tr
td
code
sourceurl
td
em
string
td
The location that will redirect visitors.
td
A valid URL.
td
code
http://www.example.com/index.html
tr
td
code
matchwww_text
td
em
em
string
td
Whether the redirection handles the www. subdomain in addition to the domain.
td
ul
li
code
checked
 — Redirect the www. subdomain.
li
code
unchecked
— Do 
strong
not
 redirect the 
code
www
. subdomain.
td
code
checked
tr
td
code
type
td
em
string
td
The type of redirection.
td
ul
li
code
permanent
 — A permanent redirection.
li
code
temporary
 — A temporary redirection.
td
code
permanent
tr
td
code
reason
td
em
string
td
div
p
A reason for failure.
p
This function only returns a 
code
reason
 value if it failed.
td
p
A string that describes the error.
td
code
This is an error message.
tr
td
code
result
td
em
Boolean
td
p
Whether the function succeeded.
td
ul
li
code
1
 — The function succeeded.
li
code
0
 — The function failed.
td
code
1