Forum Discussion

Joseph_Gallo_31's avatar
Joseph_Gallo_31
Icon for Nimbostratus rankNimbostratus
Jan 08, 2009

Need Assitstance in Rewriting URL

I need help in creating an iRule that will accomplish the following behavior:

 

 

When an end user types "https://www.domain.com/help" they need to be redirected to "https://www.domain.com:223/user/guide".

 

 

I can accomplish this with a simple redirect, but the browser will show "https://www.domain.com:223/user/guide" in the browser.

 

 

I want the redirect to occur but the browser to show what the user initially typed in after the redirect occurs. So the back end will send them to "https://www.domain.com:223/user/guide" but the browser window maintains "https://www.domain.com/help".

 

 

I have been battling with creating an Irule for this (Not the best at it) and below is what I have but it does not work. This iRule is defined in the Virtual Server listening on port 443. The 1st elseif statement is what I am having trouble with.

 

 

 

 

 

when HTTP_REQUEST {

 

log local0. "Request: [HTTP::uri]"

 

if {[HTTP::uri] contains "joinnow"}{

 

log local0. "Redirecting to Join Page Do not care if user sees changed URI"

 

HTTP::redirect "https://domain.com:223/page1

 

}

 

elseif {([HTTP::host] eq "domain.com") && ([HTTP::uri] eq "/help")}{

 

HTTP::header replace Host "domain.com:223"

 

HTTP::uri "/user/guide[HTTP::uri]"

 

}

 

 

elseif {[HTTP::uri] contains "erase"}{

 

log local0. "Redirecting to Erase page

 

HTTP::redirect "https://domain.com:223/remove

 

}

 

else {

 

log local0. "Redirecting to domain.com main page"

 

HTTP::redirect "https://domain.com:223/main"

 

}

 

}

 

when HTTP_RESPONSE {

 

log local0. "server address: [IP::server_addr]"

 

}

 

 

 

Any help would be greatly appreciated.
  • James_Quinby_46's avatar
    James_Quinby_46
    Historic F5 Account
    It sounds like you're looking for a way to proxy requests for https://www.domain.com/help to https://www.domain.com:223/user/guide.

     

     

    Take a look at the irule here:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/ProxyPass.html

     

     

    Jump down to the description - I've a feeling that this will fit the bill for you.