Skip to content

Controller

isSafeRedirectUrl()

isSafeRedirectUrl() — returns boolean

Available in: controller Category: Miscellaneous Functions

Returns true when redirectUrl stays on this site: a relative URL, or an absolute or protocol-relative URL whose host is the current server. This is the same rule redirectTo(url=…) applies before it redirects, so use it to check a return-to URL (for example params.return_to) before storing it or building a link from it.

NameTypeRequiredDefaultDescription
redirectUrlstringyes—The URL to check.
serverNamestringno[runtime expression]The host to compare against. Defaults to the current request’s server name.