Description

This function adds a redirect to your .htaccess file.


Examples 




$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
$add_redirect = $cpanel->api1('Mime', 'add_redirect', array('http://www.example.com/redirect-me','permanent','http://www.example.com/go-here-instead','example.com','0','0') ); // Call the function.



my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
my $add_redirect = $cpliveapi->api1('Mime', 'add_redirect', ['http://www.example.com/redirect-me','permanent','http://www.example.com/go-here-instead','example.com','0','0'] ); # Call the function.


<cpanel Module="Mime::add_redirect( $FORM('src','type','url','domain',wildcard',rdwww') )">




cpapi1 --user=username Mime add_redirect http://www.example.com/redirect-me permanent http://www.example.com/go-here-instead example.com 0 0


This function does not return output.



Parameters

ParameterTypeDescriptionPossible ValuesExample
src
string

Required

The URL to redirect.

Any valid URL.
http://www.example.com/redirect-me
type
string

Required

Whether the redirect is temporary or permanent.

  • temp - use return code 301  — The redirect is temporary.
  • permanent - use return code 302  — The redirect is permanent.
temp - use return code 301
urlstring

Required

The URL to which to redirect the visitor.

A valid URL.
http://www.example.com/go-here-instead
domainstring

Required

The domain to which to redirect visitors.

A valid domain.

To redirect all of the account's domains, use a period followed by an asterisk. (.*) 


example.com
wildcardBooleanWhether to redirect all files within a directory to the same filename within the destination directory.
  • 1 — Redirect all files within the directory.
  • 0 — Do not redirect all files within the directory.
0
rdwwwintegerWhether to apply the redirect to domains with and without the www hostname.
  • 2 — Redirect redirect only www. hostname.
  • 1 — Redirect all but www. hostname.
  • 0 — Redirect with or without www. hostname.
0

Returns

This function does not return output.