Child pages
  • cPanel API 1 Functions - Mime::add_redirect

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

Excerpt

This function adds a redirect to your .htaccess file.


Warning
titleWarning:

Include Page
LIB:_cPanelAPI1NewerFunctions
LIB:_cPanelAPI1NewerFunctions

  • UAPI (recommended) Mime::add_redirect
    Excerpt Include
    DD:UAPI Functions - Mime::add_redirectDD:
    UAPI Functions - Mime::add_redirect
    nopaneltrue
  • cPanel API 2 None.

Multiexcerpt include
SpaceWithExcerptcom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@12665
MultiExcerptNameAPIDisabledWebServerRole
PageWithExcerptLIB:_ServerRoleDisabledAPI

Panel
bgColor#F2F2F2
borderStylenone

Examples 


Panel
bgColor#FFFFFF
borderStylenone


Expand
titleLiveAPI PHP Class


Code Block
languagephp
linenumberstrue
$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.

Include Page
LIB:_LiveAPIPHPLink
LIB:_LiveAPIPHPLink


Expand
titleLiveAPI Perl Module


Code Block
languageperl
linenumberstrue
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.

Include Page
LIB:_LiveAPIPerlLink
LIB:_LiveAPIPerlLink


Expand
titlecPanel Tag System (deprecated)

Include Page
LIB:_cPanelTagsWarning
LIB:_cPanelTagsWarning

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



Expand
titleCommand Line


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

Include Page
LIB:_cPanelAPI1CLINote
LIB:_cPanelAPI1CLINote


Expand
titleOutput (none)

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.

Note
titleNote:

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.