Forum Discussion
Fixing external links (replace escaped ? and =)
Hi All,
I've been asked if our BigIPs can fix an issue with external links. We see them and sometimes the URL contains escaped question marks and equals signs. I am running 11.5.1 HF3 with ASM enabled VIPs and I'm looking for a technique to fix the escaped chars and pass it down to the pool.
In short, how can I convert something like this:
http://www.mysite.com/dostuff.asp%3fid%3dsomething
into this:
http://www.mysite.com/dostuff.asp?id=something
There must be a tidy irule or something?
Thanks, Mike
5 Replies
- Ryannnnnnnnn
Altocumulus
Hi mate,
here's one for you:
when HTTP_REQUEST { Disable the stream filter for all requests STREAM::disable remove the compression offerings from the client HTTP::header remove "Accept-Encoding" } when HTTP_RESPONSE { Check if response type is text if {[HTTP::header value Content-Type] contains "text"}{ Replace STREAM::expression {@%3f@?@@%3d@=@} Enable the stream filter for this response only STREAM::enable } }You'll need to apply a stream profile to your virtual server too.
- Mike_Sullivan_2
Nimbostratus
Ryan,
Thanks for your reply. That is very interesting. Would a stream operation be more efficient that a string map operation over the URL?
Also, will this work on inbound gets? I need to intercept bad external links and this looks like it will fix replies.
Thanks, Mike
- Mike_Sullivan_2
Nimbostratus
Thanks all for helping me get the gears turning. I think I have a solution and I'd like some expert feedback (in case it's just a bad approach).
Here is the rule I came up with:
when HTTP_REQUEST { set ::theuri [HTTP::uri] log local0. "the URI is $::theuri" switch -glob $::theuri { "*%3[fFdD]*" { set ::myuri [string map -nocase {"%3f" "?" "%3d" "="} $::theuri] HTTP::redirect "http://[HTTP::host]$::myuri" } } }Let me know what you think.
Thanks, Mike
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
