Forum Discussion
Irule for an URI redirection
Try this:
when HTTP_REQUEST {
set NEW_URI "/resource2"
switch -glob [string tolower [HTTP::uri]]
"/resource1"
{
HTTP::respond 301 Location "https://[HTTP::host]$NEW_URI"
}
}- ThiyaguJan 21, 2020
Cirrus
Thanks Leonorodo for helping me. For some reason these irule are not working as expected while executing the traffic flow:
==============================irule 2========To replace the URI to the server
when HTTP_REQUEST {
if {[string tolower [HTTP::uri]] starts_with "/resource1"}{
set newuri [string map -nocase {"/provision" "resource2"}[HTTP::uri]]
HTTP::uri $newuri
pool POOL1
}
}
====================================
===============irule 3================To redirect back to the client with an new URI value for further communications
===================================
when HTTP_REQUEST {
set NEW_URI "/resource2"
switch -glob [string tolower [HTTP::uri]] {
"/resource1" {
HTTP::redirect 301 "https://[HTTP::host]$NEW_URI"
}
}
}
=========================================
Could you please help me to fix the issue?
Regards,
Thiyagu
- jaikumar_f5Jan 21, 2020
Noctilucent
Can you define what is not working. Hows the flow going to and fro and what is being seen and what are you expecting. The above shared should do the trick unless something is rewriting it and goes unexpected.
- ThiyaguJan 21, 2020
Cirrus
Hi Jaikumar,
The expected goal is as below:
Option 1:
From client to LB:
https://www.domain1.com/resource1
From LB to the server:
https://www.domain1.com/resource2
If the above option is difficult to achieve it then we can try for the below option:
Option2:
From client to LB:
https://www.domain1.com/resource1
From LB to the client with redirection 301:
https://www.domain1.com/resource2
I have tried irule for both the option and the results are as below:
Option 1: all the URI values are replaced with the value of /resource2
Option2: I'm getting blank page
Could you please help me to identify if i'm missing something to meet my objective?
Regards,
Thiyagu
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