Hi 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