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

URL redirection irule

Preet_pk
Altostratus
Altostratus

Hi,

Please share below irule syntax for below URL redirection.

https://excample.com:9085/ldmcatalog/* to  https://excample.com/ldmcatalog/*

1 ACCEPTED SOLUTION

JRahm
Community Manager
Community Manager

This solution @Paulius shares here is 💯 as is, but for those looking for the slightest optimizations, you could swap out the HTTP::uri in the conditional and swap in HTTP::path, which will be a shorter comparison if there are any query parameters on the requests. Very minimal benefits, but if you obsess over every CPU cycle...

View solution in original post

3 REPLIES 3

Paulius
MVP
MVP

@Preet_pk The following iRule should do what I believe you are describing above.

when HTTP_REQUEST priority 500 {

    if {([HTTP::host] == "example.com:9085") && ([string tolower [HTTP::uri]] starts_with "/ldmcatalog/") } {
        HTTP::redirect "https://example.com[HTTP::uri]"
    }

}

JRahm
Community Manager
Community Manager

This solution @Paulius shares here is 💯 as is, but for those looking for the slightest optimizations, you could swap out the HTTP::uri in the conditional and swap in HTTP::path, which will be a shorter comparison if there are any query parameters on the requests. Very minimal benefits, but if you obsess over every CPU cycle...

LiefZimmerman
Community Manager
Community Manager

@Preet_pk - If your post was solved it would be helpful to the community to select *Accept As Solution*.
This helps future readers find answers more quickly and confirms the efforts of those who helped.
Thanks for being part of our community.
Lief