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

irule url host replacement

Fernando_M
Altocumulus
Altocumulus

Hello team,

We have an appplication changing it's url from  url.domain.com to newurl.domain.com

https://url.domain.com/<PATH> -> https://newurl.domain.com/<PATH>

I am wounder if we can replace host url of all incoming trafic and redirecting to new urls:

Example of incoming Urls:

https://url.domain.com/home/das/2134

https://url.domain.com/dashboard/login.aspx

Desired result:

https://newurl.domain.com/home/das/2134

https://newurl.domain.com/dashboard/login.asp

In fact we need to keep all URLs as it is except main host URL that need to be replaced

Thank you

1 ACCEPTED SOLUTION

Paulius
MVP
MVP

@Fernando_M I believe what you're looking for is the following. I believe the only gotcha would be that you are perform SSL termination on that virtual server and you have an HTTP profile associated to it and then add this iRule to the virtual server in question. If you need this on the HTTP side you can use the same iRule as long as your intent is to keep everyone on HTTPS.

when HTTP_REQUEST priority 500 {

    if { [HTTP::host] == "url.domain.com" } {
        HTTP::redirect "https://newurl.domain.com/[HTTP::uri]"
    }

}

 

View solution in original post

2 REPLIES 2

Paulius
MVP
MVP

@Fernando_M I believe what you're looking for is the following. I believe the only gotcha would be that you are perform SSL termination on that virtual server and you have an HTTP profile associated to it and then add this iRule to the virtual server in question. If you need this on the HTTP side you can use the same iRule as long as your intent is to keep everyone on HTTPS.

when HTTP_REQUEST priority 500 {

    if { [HTTP::host] == "url.domain.com" } {
        HTTP::redirect "https://newurl.domain.com/[HTTP::uri]"
    }

}

 

Hello Paulius,

Thank you for your feedback

I tested this and it's working perfectly until now, I will close post now with accept solution

Thank's again,