Forum Discussion
Replace part of URI
Hi,
I am looking for an Irule to replace a part of URI.
URL = something/abc/azerty
I want to rewrite on server side to :
URL = thing.abc/azerty
Which command can select the first part of URI between /...../ ??
Thanks !
- Snl
Cirrostratus
- Try below
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/something/abc/azerty" } { HTTP::uri [string map {"/something/abc/azerty" "/thing.abc/azerty"} [HTTP::uri]] } }
- Francois
Nimbostratus
It works but i want to do this :
the client put in URL "something/abc/azerty
F5 modifies this to "thing.abc/azerty"
There is something behind this URL that i don't know (/test/page.html)
When the server behind F5 respond, it sends a 302 to "thing.abc/azerty/noreply.html"
Then the client has a 302 but he don't know this internal URL.
How can i do to modify the response ?
I find
when HTTP_RESPONSE
we can change the "Location" but how to modify the Host-response and the URI-response ?
Thanks !
- Francois
Nimbostratus
when HTTP_REQUEST { #log "URL : [HTTP::host]" #log "URI : [HTTP::path]" set URIclient [getfield [HTTP::uri] "/" 2] log "URIclient = $URIclient" set URIpath [getfield [HTTP::uri] "/" 3] #log "URIpath = $URIpath" set URIpathdef [string map -nocase [list /$URIclient ""] [HTTP::uri]] log "URIpathdef = $URIpathdef" if { [SSL::verify_result] == 0 }{ #log "Certificat OK" HTTP::header insert "SSL_CLIENT_CERT" [X509::whole [SSL::cert 0]] HTTP::header replace Host "thing.$URIclient" HTTP::uri $URIpathdef #log "Acces = [HTTP::host][HTTP::uri]" } } when HTTP_REQUEST_SEND { } when HTTP_RESPONSE { log "STATUS : [HTTP::status]" log "LOCATION : [HTTP::header value "Location"]" }
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