Forum Discussion
odd behaviour with # in uri
Hi,
I have an irule performing various redirects. However, we've found that if the uri contains a after a / it matches a rule we don't want it to. For example:
https://www.company.coom/finance//isin:[{%22isin%22:%22HAU0123456%22
should not get redirected but is matching this:
elseif { [HTTP::uri] ends_with "/"} { HTTP::respond 301 Location "https://www.company.com[HTTP::uri]default.page" }
which ends up sending you to https://www.company.coom/finance/defautl.page/isin:[{%22isin%22:%22HAU0123456%22 which of course doesn't exist.
So why is / being treated as ends_with / and how do I stop this kind of uri getting caught by this rule?
thanks
A
2 Replies
- JG
Cumulonimbus
"" is a fragment identifier that is supposed to be processed on the client side only. The [HTTP::uri] on the server side does the right thing by ignoring it as part of the URI when matching. But there seems inconsistency here, as the fragment also gets appended when "HTTP::respond 301 Locatin" is called, as part of URI.
You can probably get at "" from the request header by calling HTTP::request and then parsing it.
- JG
Cumulonimbus
Here's a simple work-around:
when HTTP_REQUEST { set test_uri [HTTP::uri] if { $test_uri ends_with "/" } { HTTP::respond 301 Location "http://www.company.com/docroot" } elseif { $test_uri eq "/xxxxx" } { HTTP::respond 301 Location "https://www.company.com/xxxxx" } else { set r "https://www.company.com[HTTP::uri]default.page" HTTP::respond 301 Location $r } }
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