Forum Discussion

dionlbc_22838's avatar
dionlbc_22838
Icon for Nimbostratus rankNimbostratus
Jan 18, 2012

Host and URI rewrite

Hi All,

 

 

I'm stepping in to help with an F5 configuration while our person who is primarily responsible is out on maternity leave. I'm looking to do what seems to be a simple redirect of the hostname and URI.

 

 

 

I'm trying to redirect the following -

 

 

 

http://corporate.company.com/products/pwa

 

 

 

redirects to

 

 

 

http://project.company.com/products/pwa

 

 

 

I would like to keep any paths beyond /pwa in the URL when the redirection is made if possible.

 

 

 

Thanks for any and all help! :)

 

  • Hi,

    If you want the client to see the project.company.com hostname, you can send them a 302 redirect with an iRule like this:

    
    when HTTP_REQUEST {
    
    if {[string tolower [HTTP::host]] eq "corporate.company.com"\
    and [string tolower [HTTP::uri]] starts_with "/products/pwa"}{
    HTTP::redirect "http://project.company.com[HTTP::uri]"
    }
    }
    

    If you want to hide the project.company.com host name from the client you can use the ProxyPass iRule:

    http://devcentral.f5.com/wiki/iRules.proxypassv10.ashx

    Aaron
  • Hi there! I'm new to iRules and was wondering how I could do a similar thing but have it redirect all requests but keep the trailing path. ie:

     

     

    http://corporate.company.com/Bananas redirects to:

     

     

    http://development.company.com/Bananas

     

     

    where Bananas could be any path at all.
  • Hi Ruddiger,

    Just a minor modification to the solution that Hoolio posted would do what you are needing:

     
    when HTTP_REQUEST {
    if {[string tolower [HTTP::host]] eq "corporate.company.com" } {
            HTTP::redirect "http://development.company.com[HTTP::uri]"
        }
    }