Forum Discussion
ukitsysadmin_95
Jan 17, 2011Nimbostratus
Old URL 404, compare URI with external data group file
Hello all, I was wondering if someone could help me or point me in the correct direction. I have about 40,000 URL's and growing which need redirecting, here is an...
Colin_Walker_12
Jan 20, 2011Historic F5 Account
Aaron's got the idea for sure, and gave you the expression you'll need to get the end of the URI. All you need to do is perform the check on the response code and do the class lookup.
So what you're looking for is something like:
when HTTP_REQUEST {
set uri_token [string range [HTTP::path] [expr {[string last / [HTTP::path]] + 1}] end]
}
when HTTP_RESPONSE {
if {[HTTP::status] == 404} {
set red_uri [class match -value $uri_token equals class_name]
HTTP::redirect $red_uri
}
}
This would have a class called "class_name" with a format like:
class_name {
"man-in-band" := "http://www.xyz.com/event/98473/man-in-band",
"band-in-park" := "http://www.xyz.com/venue/9383783/band-in-park"
}
Of course, if you wanted to re-use the host name or other parts of the URL so you don't have to specifically set the entire URL to redirect to in the class, you could do that, but this should show you how the idea works, anyway.
Colin
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