Forum Discussion
Josh_Abaire
Nimbostratus
Oct 23, 2012Modify one part of URI Path
I need to change one portion of a URI path based on the value of another portion. For example:
http://www.example.com/dir1/dir2/file.ext?arg1=val1&arg2=val2&arg3
If dir2 then change...
nitass
Employee
Oct 24, 2012is this applicable?
[root@ve10:Active] config b virtual bar list
virtual bar {
snat automap
pool foo
destination 172.28.19.79:80
ip protocol 6
rules myrule
profiles {
http {}
tcp {}
}
}
[root@ve10:Active] config b class foo_class list
class foo_class {
"/dir2/" { "/dir1/ /dir5/" }
}
[root@ve10:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
if { [class match -- [HTTP::uri] contains foo_class] } {
set uri [string map [class match -value [HTTP::uri] contains foo_class] [HTTP::uri]]
HTTP::redirect "http://[HTTP::host]$uri"
}
}
}
[root@ve10:Active] config curl -I "http://172.28.19.79/dir1/dir2/file.ext?arg1=val1&arg2=val2&arg3"
HTTP/1.0 302 Found
Location: http://172.28.19.79/dir5/dir2/file.ext?arg1=val1&arg2=val2&arg3
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve10:Active] config curl -I "http://172.28.19.79/somethingelse/file.ext?arg1=val1&arg2=val2&arg3"
HTTP/1.1 404 Not Found
Date: Wed, 24 Oct 2012 00:18:48 GMT
Server: Apache/2.2.3 (CentOS)
Connection: close
Content-Type: text/html; charset=iso-8859-1
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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