Forum Discussion
HTTP redirect with URI replacement without using [http::host]
I am redirecting a https request when uri /ExampleWeb* is requested it is changed to /ExampleWeb/test* then is being redirected to http (all other uri will stay https). The issue I am having is that when it is being redirected using [http::host] the server in the pool doesn't have the host in its directory. So I would like to be able to redirect it to http but the only thing that stays is the uri (allowing the VIP to change the host). This is what I have currently which still keeps the http host. FYI the uri is case sensitivity so I can't use tolower. I don't know if this is the best way or to point it to a new pool and keep the uri.
when HTTP_REQUEST {
if {[HTTP::uri] contains "/ExampleWeb"}{
log "Requested URL is [HTTP::host][HTTP::uri]"
HTTP::uri [string map {"/ExampleWeb" "/ExampleWeb/text"} [HTTP::uri]]
HTTP::redirect "http://[HTTP::host][HTTP::uri]"
}
}
- nitass_89166Noctilucent
I am redirecting a https request when uri /ExampleWeb* is requested it is changed to /ExampleWeb/test* then is being redirected to http.
if i understand correctly, you do not need HTTP::redirect command. you just create http pool and assign to virtual server.
The issue I am having is that when it is being redirected using [http::host] the server in the pool doesn't have the host in its directory.
you can use HTTP::header to change host header value.
HTTP::header replace Host (new host header value)
- rjones_01_14578NimbostratusThanks nitass. This is what I ended up using. There is probably a better cleaner way to do this (I'm new to irules) but it is working as expected now. when HTTP_REQUEST { if {[HTTP::uri] contains "/ExampleWeb"}{ log "Requested URL is [HTTP::host][HTTP::uri]" HTTP::uri [string map {"/ExampleWeb" "/ExampleWeb/test"} [HTTP::uri]] switch -glob [HTTP::path] { "ExampleWeb/test*" { virtual test-instance-80 } } } }
- nitassEmployee
I am redirecting a https request when uri /ExampleWeb* is requested it is changed to /ExampleWeb/test* then is being redirected to http.
if i understand correctly, you do not need HTTP::redirect command. you just create http pool and assign to virtual server.
The issue I am having is that when it is being redirected using [http::host] the server in the pool doesn't have the host in its directory.
you can use HTTP::header to change host header value.
HTTP::header replace Host (new host header value)
- rjones_01_14578NimbostratusThanks nitass. This is what I ended up using. There is probably a better cleaner way to do this (I'm new to irules) but it is working as expected now. when HTTP_REQUEST { if {[HTTP::uri] contains "/ExampleWeb"}{ log "Requested URL is [HTTP::host][HTTP::uri]" HTTP::uri [string map {"/ExampleWeb" "/ExampleWeb/test"} [HTTP::uri]] switch -glob [HTTP::path] { "ExampleWeb/test*" { virtual test-instance-80 } } } }
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