Forum Discussion
iRule for redirection with masking for a specific URI only.
Folks,
We received some redirect requests for a very particular scenario and based on that I have come up with a iRule which I want to get some additional comments on:
The redirect requests are as below:
1) If an request is made for https://www.abc.com/manual/* the request needs to forward to https://www.newsite.com/support/txt/docs/. 2) The above redirects must be masked i.e. the end user should not know where is he going to. 3) This applies to URI's which start with "/manual" in the URI. If the keyword "manual" is seen at any other place no action should be taken. 4) The wild character "" indicates this could be any string after "/manual". 5) The redirects would also need to be https. 6) Other than this no other URI needs to be redirected.
How should the below iRule look for this request:
when HTTP_REQUEST { if { [HTTP:uri] starts_with "/manual/" } HTTP::header replace "Host" "; HTTP::uri "/support/txt/docs/" }
Thanks!! N.
- Leonardo_Souza
Cirrocumulus
Have a look at this answer:
https://devcentral.f5.com/questions/uri-translation-vs-httpredirect-irule-52327
I modified your iRule, you will have to test:
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/manual/" } { HTTP::header replace "Host" "www.newsite.com" set uri [string range [HTTP::uri] 8 end] HTTP::uri "/support/txt/docs/$uri" } }
The logic is correct, but you had multiple syntax errors. Also, you need to send the remaining of the URI to the server.
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