Forum Discussion
F5Hopper_28651
Nimbostratus
Jul 25, 2016wildcard URL redirection with wildcard as part of URL
Not sure how to do this, its a PURL project.
Original PURL: firstname-lastname.www.somesite.com
Re-direct address: www.somesite.com/personal-landing/index.asp?cust=firstname-lastname
no idea where to start.
Code
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host][HTTP::path]] {
"[HTTP::?].www.somesite.com" {
HTTP::redirect "http://www.somesite.com/personal-landing/index.asp?cust=[HTTP::?]"
}
}}
4 Replies
- Vijay_E
Cirrus
Untested but try something using getfield:
when HTTP_REQUEST { set HOST [string tolower [HTTP::host]] set USER [getfield $HOST "." 1] set SITE [getfield $HOST "." 2] HTTP::redirect "http://$SITE/personal-landing/index.asp?cust=$USER" } - JG
Cumulonimbus
Try this one:
when HTTP_REQUEST { HTTP::redirect "http://www.somesite.com/personal-landing/index.asp?cust=[string tolower [lindex [split [HTTP::host] "."] 0]]" }.
- F5Hopper_28651
Nimbostratus
I found my answer. now any DEV server with DEV01 or DEV99 will change on request.
when HTTP_REQUEST { set HOST [string tolower [HTTP::host]] set USER [getfield $HOST "." 1] set DEV [getfield $HOST "." 2] set SITE [getfield $HOST "." 3] HTTP::redirect "http://$DEV.www.somesite.com/personal-landing/index.asp?cust=$USER" }- F5Hopper_28651
Nimbostratus
ok I removed one line(set SITE [getfield $HOST "." 3]) now it all worked 100% in chrome and Safari..I guess since it was not being used it was a problem...
when HTTP_REQUEST { set HOST [string tolower [HTTP::host]] set USER [getfield $HOST "." 1] set DEV [getfield $HOST "." 2] HTTP::redirect "http://$DEV.www.somesite.com/personal-landing/index.asp?cust=$USER" }
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