Forum Discussion
Preserve URL prefix during redirect
We're migrating our client URLs to a new domain. We have one VS for all clients as they're directed to their content at the server level.
Here's what needs to be done:
the VIP and DNS name is prod.stiniflap.com The new domain is prod.information.com
The Acme client would use acme.prod.stiniflap.com and at the DNS level would be forwarded to the prod.stiniflap.com VS.
I need to put a redirect rule in place that directs the client to the new domain but maintains their the "Acme" portion of the URL.
Here's what I've come up with:
when HTTP_REQUEST { if {[string tolower [HTTP::host]] ends_with "prod.stiniflap.com"} { HTTP::redirect "https://prod.information.com[HTTP::uri]" } } }
Unfortunately I don't believe that this will maintain the client name with the new domain.
- Hectorm
Nimbostratus
acme.prod.stiniflap.com is actually the host. So you do not want to change the host to prod.information.com in the browser or do you want to change the host acme.prod.infortation.com? I am not clear when you say you want to maintain the acme name.
- Woody_
Nimbostratus
If I client hits the VS via acme.stinaflap.com, I want redirect to be to acme.information.com. icecream.stinaflap.com to icecream.information.com
prod.stinaflap.com and prod.information.com are the virtual server and DNS host names (not visible to the clients), we're using CNAME wildcard forwarders to push them to the VS.
- Hectorm
Nimbostratus
So for this all you need to do is used the string trim command. Something like this when HTTP_REQUEST {
set Vhost [ string tolower [HTTP::host]] set Vclient [string trim [HTTP::host] ".prod.stiniflap.com"] set NewHost ".pro.imformation.com"
HTTP::redirect "https://$Vclient$NewHost[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