buy
Delete Redirect

Description

This API allows end users to delete an existing domain redirect configured for a domain under their account.

You must provide the domain and path of the redirect rule that needs to be removed.

Parameters

Sample Code

curl --insecure -u "username:password" "https://hostname:2003/index.php?api=json&act=redirects&delete=1&domain=example.com&path=/"
<?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';

// POST parameters
$post = array(
    'delete' => '1',
    'domain' => 'example.com',
    'path'   => '/'
);

// 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, true);

// Send POST request
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));

// Execute request
$response = curl_exec($ch);

if(curl_errno($ch)){
    echo 'Curl error: '.curl_error($ch);
}

curl_close($ch);

// Decode JSON response
$result = json_decode($response, true);

// Output result
if(!empty($result['done'])){
    echo "Redirect deleted successfully";
    print_r($result['done']);
}else{
    print_r($result['error']);
}

?>

Output

"done": {
    "msg": "Redirect deleted successfully"
  }
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list