Description
This API allows end users to retrieve the list of configured domain redirects for the domains under their account.
It returns the redirect rules including path, redirect type, and destination address for each domain.
Parameters
Sample Code
curl --insecure -u "username:password" "https://hostname:2003/index.php?api=json&act=redirects"<?php
$user = 'your_user';
$pass = 'your_password';
$ip = 'your_ip';
// API URL
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$ip.':2003/index.php?api=json&act=redirects';
// Initialize cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Execute request
$resp = curl_exec($ch);
if(curl_errno($ch)){
echo 'Curl error: '.curl_error($ch);
}
curl_close($ch);
// Decode JSON response
$res = json_decode($resp, true);
// Print result
if(!empty($res['redirects_list'])){
echo "<pre>";
print_r($res['redirects_list']);
echo "</pre>";
}else{
print_r($res['error']);
}
?>Output
Array
(
[example.com/] => Array
(
[rid] => 1
[user] => username
[domain] => example.com
[path] => /
[type] => temporary
[address] => forwarded_domain
)
)