UAPI Functions - Mime::list_redirects

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

 LiveAPI PHP Class

$cpanel new CPANEL(); // Connect to cPanel - only do this once.
  
// List redirects
$mime_list_redirects $cpanel->uapi(
    'Mime''list_redirects'
);

 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',
);

 cPanel Template Toolkit

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

 Command Line

uapi --user=username Mime list_redirects

 

Notes:

  • You must URI-encode values.
  • username represents your account-level username.

 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 (Home >> Advanced >> API Shell) to directly test cPanel API calls.

 

Parameters

 Parameter 

 Type 

Description

Possible values

Example

regex

 string 

 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

Return

Type

Description

Possible values

Example

urldomain

string

The domain to redirect.

A valid domain.

example.com

source

string

The file within the domain to test.

 A valid filename and path, relative to the home directory. 

/marceau.html

targeturl

string

The redirect's destination.

A valid URL.

http://redirect.example.com/

destination

string

The redirect's destination.

A valid URL.

 http://redirect.example.com/ 

sourceurl

string

The file within the domain to test.

A valid filename and path, relative to the home directory.

/marceau.html

displaydomain

string

The domain to redirect.

ALL is the only possible value.

ALL

displaysourceurl

string

The file within the domain to test.

A valid filename and path, relative to the home directory.

/marceau.html

wildcard_text

string

Whether the Wild Card Redirect option is active.

  • checked — Wild Card Redirection is active.

checked

 matchwww_text 

string

Whether Redirect With www.option is active.

  • checked — Wild Card Redirection is active.

checked

domain

string

The domain to redirect.

A valid domain name.

example.com

kind

string

The kind of redirect.

rewrite is the only possible value.

rewrite

docroot

string

The source domain's document root.

A valid absolute file path.

 /home/example/public_html 

matchwww

 Boolean 

 Whether the redirect matches www. subdomains. 

  • 1 — Matches.
  • 0 — Does not match.

1

type

string

Whether the redirect is permanent or temporary.

  • permanent
  • temporary

permanent

wildcard

Boolean

Whether the wildcard subdomains match.

  • 1 — Matches.
  • 0 — Does not match.

1

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....