Forum Discussion

mikey_webb's avatar
Nov 10, 2017

rewrite - help needed

i have a VS which runs 2 different sites with different host headers: abc.co.uk and def.co.uk. i want to ensure that the users never see the real redirect url for def.co.uk and normally a rewrite profile would do this however cant work out how to apply a rewrite profile to a specific host header as really for uri translation.

 

in summary i want abc.co.uk to remain as is and host header remains as abc.co.uk. i want def.co.uk to rewrite to abc.co.uk/app/login but users only see def.co.uk in url bar

 

help please!

 

  • If you redirect the user to abc.co.uk, the browser will update to reflect that.

    If you want the address bar to stay def.co.uk, you can't redirect the user. Rather, you'd need to do the redirection locally. For example:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] equals "def.co.uk" } {
             change the Host header on the way to the server (as needed)
            HTTP::host "abc.co.uk"
    
             send to the def.co.uk pool
            pool def_pool
    
             if the URI is empty, redirect to /app/login
            if { [HTTP::uri] equals "/" } {
                 sends a relative 302 redirect to the user
                HTTP::redirect "/app/login"
            }
        }
    }
    
  • Thanks but this did not produce desired results.

     

    the uri part in the irule meant that the other url the VS served redirected which I don't want.

     

    is the way to do this not a rewrite profile - but cant see how to change host