Hello
I have been asked to redirect an url that has 15 differant paths to a new url with a modified path
Here is and expample www.xyz.com/2013/11/07/enterprise-risk-management-getting-the-tone-right/ to www.newhome.com/knowledge/blog/enterprise-risk-management-getting-the-tone-right.html
The /2013/ is the same on all request but the 11/07 could be differant
After the 11/07 its a match per url
The www.xyz.com is a vip and pool combo but the www.newhome.com is external to us.
thank you for your help in advance…
Can you provide more detail as to what you want to acheive. If you are running v11.4, you can make use of Rewrite profile to rewrite URIs. Based on what you have mentioned you might have to use iRules to accomplish it. That is, rewrite URL and URI on HTTP_REQUEST and rewrite the URLs and URIs back on HTTP_RESPONSE.
sorry for format issue, going from www.genreperspective,com to www.genre.com / 2013 is common incomming request
Something like this:
when HTTP_REQUEST {
set uri_end [getfield [HTTP::uri] "/" 5]
set uri_start "http://www.xyz.com/abc123/this-is-the-new-URL/"
HTTP::redirect "$uri_start$uri_end"
}
You have an errant closing square bracket after your conditional if statement and the “genreperspective” string would be in the [HTTP::host] value, not the [HTTP::path]. Otherwise, if you can guarantee that the “/2013/x/x” URI pattern always exists before the URI portion that you want to capture, then you can also do this:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "www.genreperspective.com" } {
set newuri [lindex [split [HTTP::uri] "/"] 4]
HTTP::redirect "http://www.genre.com/knowledge/blog/${newuri}.html"
}
}
This is simply splitting the incoming URI into a list and plucking out the 5th element (similar to Pete’s getfield command).
Thank you I will give this a try, Looks promising