cPanel setredirecturl api function


Well-Known Member
Sep 13, 2006

I'm having a tough time figuring out how to set the redirect URL for a domain I've just parked. I don't seem to be able to do it via the API (v2) when parking the domain, and the only other function that seems to do this is Park::setredirecturl in v1 of the API. But I can't for the life of me figure out how to format the command line to work properly. I'm calling it from Perl using LWP to send a GET request and my URL looks like this:


But I get an error "Could not find function 'setredirecturl' in module 'Park'" and the XML returns version 2 of the API. So I guess it makes sense that the function doesn't exist since it's not in v2 and the API thinks I'm calling a v2 function even though I specified v1

Looking at some examples in the docs, I also tried this format:


But that returns the error "Unknown app (setredirecturll) requested for this version (1) of the API. " The docs say it's in module "Park" but I don't see where to specify the module in the version 1 format of the command I'm using.

Can anyone suggest how to accomplish parking a domain with a redirect to another http: URL via the API?



Staff member
Apr 11, 2011

You might find the following UAPI functions helpful for this purpose:

UAPI Functions - Mime::list_redirects - Software Development Kit - cPanel Documentation
UAPI Functions - Mime::delete_redirect - Software Development Kit - cPanel Documentation
UAPI Functions - Mime::add_redirect - Software Development Kit - cPanel Documentation

This will allow you to list the current redirect for a domain alias (parked domain), delete it, and add a new one with the URL of your preference. Using the UAPI command-line functionality as an example, let's say "cptest02.tld" is our alias. We can obtain information such it's target URL and current document root if a redirect already exists via a command such as:

uapi --user=$cpanel-username Mime list_redirects
Then, if a redirect exists for this domain name, it's possible to delete it via a command such as:

uapi --user=$cpanel-username Mime delete_redirect domain=cptest02.tld docroot=/home/$cpanel-username/public_html
Finally, you can add the new redirect with a command such as:

uapi --user=$cpanel-username Mime add_redirect domain=cptest02.tld redirect=http%3A%2F%2Fgoogle.tld%2F type=permanent redirect_wildcard=1 redirect_www=0
Let us know if this helps.

Thank you.