Forum Discussion
dacrud_18985
Nimbostratus
Sep 16, 2008remove everything after question mark
Hi all,
I have a URL like so:
http://www.domain.com/popular_stuff/list/5?id_session=BLAHBLAHBLAHBLAH
and I need to strip everything after the question mark and only return the path of the URL like this (in the body of the html):
/popular_stuff/list/5
Would this work:
rule strip_question {
when HTTP_REQUEST {
if { [HTTP::uri] contains "/popular_stuff/list"} {
HTTP::respond 200 content "[HTTP::path]"
}
}
}
- hoolio
Cirrostratus
Do you want to redirect the client with the updated path-only location or do you want to rewrite it before the request is sent to the pool? Do you want to do this with all requests that contain a query string?when HTTP_REQUEST { Check if there is a query string in the URI if {[string length [HTTP::query]]}{ Rewrite the URI to remove the query string HTTP::uri [HTTP::path] } }
when HTTP_REQUEST { Check if there is a query string in the URI if {[string length [HTTP::query]]}{ Redirect the client to the same host and the path (URI without the query string) HTTP::redirect http://[HTTP::host][HTTP::path] } }
- dacrud_18985
Nimbostratus
No, I need to respond with 200 content. I believe I've got it.. thanks for the help! - hoolio
Cirrostratus
If you do want to send back a response with the requested path in the payload, the rule you posted originally should work. Was there something not working with that? - dacrud_18985
Nimbostratus
Nope, it was.
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