Forum Discussion
irules to rewrite old url to new url without changing the users browser url
Reformatting your iRule for discussion:
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/test-site" } {
HTTP::header replace "Host" "newsite.test.com"
HTTP::path "/alternatesite/test"
pool newsite-pool-HTTP
} else {
pool oldsite-pool-HTTP
}
}
What you're basically saying is if the URI starts with /test-site, change the Host header, change the HTTP path, and send to a different pool. Otherwise send to the oldsite pool. I would start by changing HTTP::path to HTTP::uri. The HTTP::path is the part of the URI before any query strings, while HTTP::uri is the entire uri. The above iRule will work for the simplest environments, as long as the new site only ever uses the /alternatesite/test URI. If it doesn't, and it's in any way dynamic, then you have to do some more work. Depending on the complexity, you may want to take a look at the ProxyPass iRule (v11.3 and below) or the rewrite profiles in 11.4 and above.
You may also want to consider enabling a OneConnect profile.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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