Forum Discussion
agidwani_102403
Nimbostratus
Feb 21, 2008Need help
hello,
I need to accomplish the following
rewrite the uri https://aa.mycompany.com/compA/blah.acmx (can have companyA, Company123, CompanyABC etc)
rewrite the uri to https://aa.mycompany.com/global/blah.acmx
Note : we tried a simple redirect but receive HTTP 301 error and are stuck.
Any help would be highly appreciated.
Thanks - Arvind
8 Replies
- Nicolas_Menant
Employee
Hi, - agidwani_102403
Nimbostratus
nmenant, - Here's one option for companies "compA", "compB", and "compC". You can modify/expand this by replacing/adding new company names to the switch statement.
when HTTP_REQUEST { switch -glob [HTTP::uri] { "/compA*" - "/compB*" - "/compC*" { set comp variable to first sub dir of in uri. set comp [getfield [HTTP::uri] "/" 2] perform a string map from the found string to "global" in the URI. set newuri [string map [list $comp "global"] [HTTP::uri]] Issue a HTTP redirect to the client browser HTTP::redirect $newuri Modify the URI sent to the backend server HTTP::uri $newuri } } }
- Brian_Brown_855
Nimbostratus
Hi, - Phil_Rudich_735
Nimbostratus
We need to create an iRule with very similar characteristics to the one you describe here... for many companies as well. Was there ever a discussion on the resolution to this effort? - hoolio
Cirrostratus
Hi Phil,Issue a HTTP redirect to the client browser HTTP::redirect $newuri Modify the URI sent to the backend server HTTP::uri $newuri
- Phil_Rudich_735
Nimbostratus
Okay, finally got the proper naming convention from management and the way they want to go! - Phil_Rudich_735
Nimbostratus
This is what one of our internal programmers came up with. However, it doesn't work 100% of the time.when HTTP_REQUEST { set header [HTTP::host] set splitVals [split $header "."] set urlPartCount [llength $splitVals] if {$urlPartCount eq 4} { set firstPart [string tolower [lindex $splitVals 0]] switch $firstPart { "hrp" { set splitVals [lreplace $splitVals 0 0] lset splitVals 0 [lindex $splitVals 0]hrp } "www" { set splitVals [lreplace $splitVals 0 0] } } set returnVal [join $splitVals "."] HTTP::redirect "https://$returnVal" } }
Recent Discussions
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