Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

iRule redirection

ecwlam
Altostratus
Altostratus

May I know how to write the iRule with uri redirection?

https://www.abc.com/aa  --> https://www.abc.com/bb

including the correspoing link under https://www.abc.com/aa

For example:

https://www.abc.com/aa/xxx/yyy/ --> https://www.abc.com/aa/xxx/yyy/

 

1 ACCEPTED SOLUTION

muhamed_elfiky
Altocumulus
Altocumulus

Hi @ecwlam 

 

you can use this  IRule:

when HTTP_REQUEST {

if {[HTTP::uri] starts_with "/aa/"} {

HTTP::uri [string map {"/aa/" "/bb/"}[HTTP::uri]]

HTTP::redirect "[HTTP::uri]"

}

}

View solution in original post

8 REPLIES 8

muhamed_elfiky
Altocumulus
Altocumulus

Hi @ecwlam 

you can use this IRule :

when HTTP_REQUEST {

if { [HTTP::uri] starts_with "/aa"}{

    HTTP::redirect https://[HTTP::host]/bb

}

}

Thanks for your reply, it works with https://www.abc.com/aa  --> https://www.abc.com/bb

However, the corresponding link does not work

it will redirect from https://www.abc.com/aa/xxx/yyy --> https://www.abc.com/bb

muhamed_elfiky
Altocumulus
Altocumulus

Hi @ecwlam 

 

you can use this  IRule:

when HTTP_REQUEST {

if {[HTTP::uri] starts_with "/aa/"} {

HTTP::uri [string map {"/aa/" "/bb/"}[HTTP::uri]]

HTTP::redirect "[HTTP::uri]"

}

}

@ecwlam  - I'm going to mark the reply from the 23rd as the Accepted Solution - if it didn't solve your problem, please let me know and I'll remove the designation. 

Thanks, it works well!

Leslie_Hubertus_0-1672191799379.gif

 

Hello All, 

I am trying to a redirect with some complication. I need to redirect the URL to the backend server but keep the Friendly name in the browser.

Eg- appurl.com but the server is expecting appserverurl.com but the browser must always say appurl.com during request/response. 

Hope this makes sense. 

Mr__T
Cirrus
Cirrus

Hello All, 

I am trying to a redirect with some complication. I need to redirect the URL to the backend server but keep the Friendly name in the browser.

Eg- appurl.com but the server is expecting appserverurl.com but the browser must always say appurl.com during request/response. 

Hope this makes sense.