Forum Discussion
Richard_77286
Mar 17, 2017Nimbostratus
Help with iRule redirect
I have a request from our dev team to redirect https://www.ourwebsite.com/agentlanguagelocator to https://www.ourwebsite.com/apex_extprd/f?p=119:1. Dev team would like users to use /agentlanguagelo...
- Mar 18, 2017
Hello Richard,
Based on your iRule, you are not performing a redirect, you are only changing the URI before it is passed to the server. This is completely transparent to the user/browser.
If your Dev team has requested a redirect, it should probably look closer to this:
when HTTP_REQUEST { if {[string tolower [HTTP::uri]] eq "/agentlanguagelocator"} { HTTP::respond 302 Location "/apex_extprd/f?p=[URI::encode 119:1]" } }
Notes
- Notice the use of HTTP::respond, this is not required as HTTP::redirect will perform the same function. My preference is to use HTTP::respond so the status code is clear at all times and to any readers of the iRule.
- The match is only for the URI and it's a case-insensitive exact match. Your requirements may vary.
- If the virtual server handles multiple domain names that don't all have this desired behavior, you should include a domain name match as well.
- The Location header is /apex_extprd/f?p=119:1 and not the full URL. This is a relative redirect directing the browser to use the same scheme (e.g. http / https) and domain name as the original request, but redirect to a different path. If you need the whole URL, that should be changed.
- The value of query parameter p is wrapped with URI::encode. This is because the colon is a reserved URI character and may cause problems if not encoded. You may also directly type 119%3A1 which should be the result of using URI::encode and translates to 119:1.
Vijay_E
Mar 17, 2017Cirrus
Did you use curl to check the response from the F5 ?
curl -IL https://www.ourwebsite.com/agentlanguagelocator
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