Forum Discussion
im having problems with issuing a 302 with an iRule
Im brand new to iRules. so go easy on me :)..I have a production URL http://environment.company.com/ and I created a data group which contains 4 unique URI paths ...
My goal was if traffic comes into the production URL .. and the URI starts_with the paths in my datagroup I wanted to issue a 302 and ask end users browser to come back on a new URL while preserving their URI path.
my datagroup consists of :
/lorl/
/jc.app.settings.svc.webhost/
/jc.leader.joe.webhost/
/jc.app/settings.svc.webhost/
so when a browser hits http://environment.company.com/lorl/ i want them to get a 302 redirecting them to http://new-environment.company.com/lorl
this is what i wrote:
when HTTP_REQUEST { if { [class match [[string tolower [HTTP::uri]] starts_with DatagroupNAME ]] } { HTTP::respond 302 location "http://new-enviornment.company.com[HTTP::uri]" } }
my end user simply gets a connection reset...
- P_K
Altostratus
How is your data group defined?
i entered each of these in the group as a string:
/lorl/
/jc.app.settings.svc.webhost/
/jc.leader.joe.webhost/
/jc.app/settings.svc.webhost/
- eben
Nimbostratus
Try setting the new HTTP::host as a variable. then call it in the redirect. when HTTP_REQUEST { if { [class match [[string tolower [HTTP::uri]] starts_with DatagroupNAME ]] } { HTTP::respond 302 location "http://$[HTTP::uri]" } }
You could also use a Switch [HTTP::uri] to achieve this.
- eben
Nimbostratus
when HTTP_REQUEST{ switch [HTTP::uri] { "/lorl/"- "/jc.app.settings.svc.webhost/"- "/jc.leader.joe.webhost/"- "/jc.app/settings.svc.webhost/" { HTTP::redirect "http://new.domain.com/[HTTP::uri]"}
}
}
- eben_259100
Cirrostratus
Try setting the new HTTP::host as a variable. then call it in the redirect. when HTTP_REQUEST { if { [class match [[string tolower [HTTP::uri]] starts_with DatagroupNAME ]] } { HTTP::respond 302 location "http://$[HTTP::uri]" } }
You could also use a Switch [HTTP::uri] to achieve this.
- eben_259100
Cirrostratus
when HTTP_REQUEST{ switch [HTTP::uri] { "/lorl/"- "/jc.app.settings.svc.webhost/"- "/jc.leader.joe.webhost/"- "/jc.app/settings.svc.webhost/" { HTTP::redirect "http://new.domain.com/[HTTP::uri]"}
}
}
Recent Discussions
Related Content
* 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