Forum Discussion
Misty_Spillers
Oct 04, 2011Nimbostratus
Omiting a portion of a redirect
This seems like it would be easy but just can't quite find the answer.
One of our customers used to be hosted under our main web site now they have moved the site to a vanity domain. I'm trying to redirect possible book marks to the old site but I need to omit part of the uri.
So they want http://www.oursite.com/theirsite/about.shtml to go to http://www.theirsite.com/about.shtml
The way I normally do this is: (this is in a long rule handling other stuff as well so that's why it not properly formatted)
if { [string tolower [HTTP::host]] contains "oursite.com" and [string tolower [HTTP::uri]] starts_with "/theirsite" } {
HTTP::redirect "http://www.theirsite.com/[HTTP::uri]"
} else {
But it ends up http://www.theirsite.com/theirsite/about.shtml
any easy way to omit the /theirsite?
3 Replies
Sort By
- URI::path
- sorry i think this may be easier.
[root@tulip:Active] config b virtual bar list virtual bar { destination 172.28.17.66:http ip protocol tcp rules myrule profiles http tcp } [root@tulip:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if {[string tolower [HTTP::host]] ends_with "oursite.com" and [string tolower [HTTP::uri]] starts_with "/theirsite"} { HTTP::redirect "http://www.theirsite.com[string range [HTTP::uri] 10 end]" } } } [root@tulip:Active] config curl -I http://www.oursite.com/theirsite/test/about.shtml HTTP/1.0 302 Found Location: http://www.theirsite.com/test/about.shtml Server: BigIP Connection: Keep-Alive Content-Length: 0
- Thank you! that worked perfectly so far!
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