mod_rewrite equivalent in irule
I got a request to implement below equivalent of Apache mod_rewrite in F5 using irule.
RewriteCond %{REQUEST_URI} ^/Alias/Web/Main$ [NC]
RewriteCond %{REMOTE_ADDR} ^194\.156\.44\.([0-9]|[1-5][0-9]|6[0-3])$ [NC]
RewriteCond %{HTTP_COOKIE} !userLoggedIn=true [NC]
RewriteRule ^(.*)$ http://aliassso-prod [R=301,L]
Below is what I did in iRule. Since we have to ask our customer to test it, would like to understand if this would work. Atleast, I could test the redirection with my source IP and it works.
if { [URI::decode [string tolower [HTTP::uri]]] matches_regex "^/alias/web/main$" } {
if { [IP::addr [IP::client_addr] equals 194.156.44.0/24 ] } {
if { ![HTTP::cookie exists "userLoggedIn=true"] } {
HTTP::respond 301 noserver Location "http://aliassso-prod"
}
}
}
Thanks in advanced.