HTTPRedirect[uri]
represents an HTTP redirect to the specified uri.
HTTPRedirect[uri,metadata]
represents an HTTP redirect to uri with the specified metadata.
HTTPRedirect
HTTPRedirect[uri]
represents an HTTP redirect to the specified uri.
HTTPRedirect[uri,metadata]
represents an HTTP redirect to uri with the specified metadata.
Details
- The redirect location uri can be either a string representing an explicit URL or a CloudObject.
- HTTPRedirect is usually stored in a CloudObject or specified as the result in an APIFunction or FormFunction.
- HTTPRedirect[…] can be deployed to the cloud using CloudDeploy.
- The metadata in HTTPRedirect is an association including the following possible elements:
-
"StatusCode" 302 HTTP status code "ContentType" "text/html" MIME type for content "Cookies" {} cookies to set "Headers" Automatic a list of rules giving HTTP response headers
Examples
open all close allBasic Examples (1)
CloudDeploy @ Delayed[HTTPRedirect["http://www.wolfram.com/"]]Use inside APIFunction:
CloudDeploy @ APIFunction[
"url" -> "SemanticURL",
Composition[HTTPRedirect, First]
]Use inside FormFunction:
CloudDeploy @ FormFunction[
"query" -> <|"Hint" -> "Search", "Label" -> None|>,
HTTPRedirect[URLBuild["https://en.wikipedia.org/w/index.php", {"search" -> #query}]]&
]Scope (1)
By default, HTTPRedirect creates a redirect. A temporary redirect is not cached by the browser:
CloudDeploy @ Delayed[
HTTPRedirect[URLBuild["http://www.wolfram.com", {"noonce" -> RandomInteger[{1, 2000}]}]]
]Use a permanent redirect and the browser will cache the response:
CloudDeploy @ Delayed[
HTTPRedirect[
URLBuild[
"http://www.wolfram.com",
{"noonce" -> RandomInteger[{1, 2000}]}
],
<|"StatusCode" -> 301|>
]
]Neat Examples (1)
Create a form function that is redirecting to a new URL:
CloudDeploy[FormFunction[{"Website" -> <|"Interpreter" -> "SemanticURL", "Input" -> "Wikipedia"|>}, Composition[HTTPRedirect, First], AppearanceRules -> <|"Title" -> "WebGo!", "Description" -> "Write the name of any website, and we will take you there!", "SubmitLabel" -> "Go!"|>]]See Also
HTTPResponse URLBuild CloudDeploy HTTPErrorResponse FollowRedirects
Function Repository: HTTPLanguageRedirect
Related Guides
Related Workflows
- Deploy a Web API
History
Text
Wolfram Research (2014), HTTPRedirect, Wolfram Language function, https://reference.wolfram.com/language/ref/HTTPRedirect.html.
CMS
Wolfram Language. 2014. "HTTPRedirect." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HTTPRedirect.html.
APA
Wolfram Language. (2014). HTTPRedirect. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HTTPRedirect.html
BibTeX
@misc{reference.wolfram_2026_httpredirect, author="Wolfram Research", title="{HTTPRedirect}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/HTTPRedirect.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_httpredirect, organization={Wolfram Research}, title={HTTPRedirect}, year={2014}, url={https://reference.wolfram.com/language/ref/HTTPRedirect.html}, note=[Accessed: 12-June-2026]}