Forum Discussion
amass87_221296
Nimbostratus
Sep 02, 2016URL redirect with Data Group
I am trying to use data groups to redirect URL, however the data group value is just appending to the end of the original URL in the web browser. Same result in Chrome, IE, and Firefox. I am not su...
Kai_Wilke
MVP
Sep 02, 2016Hi Amass87,
take a look to the iRule below. It uses a slightly optimized syntax (just a single [class] execution) and also point out the reason why you're not getting redirected to external sites...
when HTTP_REQUEST {
if { [set redirect [class match -value "[HTTP::host][HTTP::uri]" equals datagroup_redirects]] ne ""} then {
HTTP::redirect "$redirect" ; Redirect to a sub-path/file within the current path
HTTP::redirect "/$redirect" ; Redirect to a sub-path/file relational to / (www-toot)
HTTP::redirect "//$redirect" ; Absolute Redirect protcol independent
HTTP::redirect "http://$redirect" ; Ablsolte Redirect to HTTP
HTTP::redirect "https://$redirect" ; Absolute Redirect to HTTPS
}
}
Note: I would recommend to add the location prefixes directly into your datagroup. On this way you could specify them per entry as needed.
Cheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects