Forum Discussion
Re-write URI on server response
I need to modify the URI in the HTTP Response. My VIP is listening on 443 and Pool members are on 80. Client request has "/abc/app/index.html/xyz" as the URI and server response removes " index.html" and gives back "/abc/app//xyz" to the client.
When client refreshes the page or reconnects to the URI "/abc/app//xyz" client gets back to a login page that he has no access to.I want to replace server response URI with the original URI in the client request "/abc/app/index.html/xyz".
I have tried few irules but did not help.
- youssef1Cumulonimbus
Hi,
the response of the server is 302? if yes try this irule:
when HTTP_RESPONSE { if { [HTTP::status] contains "302" && [string tolower [HTTP::header Location]] contains "/abc/app//xyz" } { HTTP::header replace Location [string map -nocase {"/abc/app//xyz" "/abc/app/index.html/xyz"} [HTTP::header Location]] } } }
Regards
- Lee_SutcliffeNacreous
You need to be careful using ‘’ in your URI
RFC at 3986 https://tools.ietf.org/html/rfc3986 (which defines how a URI is structured) it states that is a reserved character and is defined as a delimiter (much like : / ? etc).
The '' character is defined as a fragment (see Section 3) And defined further in section 3.1 - an except is provided below:
The fragment identifier component of a URI allows indirect identification of a secondary resource by reference to a primary resource and additional identifying information. The identified secondary resource may be some portion or subset of the primary resource, some view on representations of the primary resource, or some other resource defined or described by those representations. A fragment identifier component is indicated by the presence of a number sign ("") character and terminated by the end of the URI.
As F5 will follow the relevant RFCs when defining commands such as HTTP::uri, using a '' character in a URI will cause the command to only extract the left most portion of the URI BEFORE the '' as the intended use of '' is as a fragment delimiter.
I would advise that you do not use '' delimiters in your URI unless you are doing so as per RFC3986 guidelines
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