Forum Discussion

mfrench_267209's avatar
mfrench_267209
Icon for Nimbostratus rankNimbostratus
Dec 16, 2016

Rewriting the HOST and part of the URI

Here's the goal:

 

 

should load the website from:

 

 

I've successfully replaced the domain/host using the following code:

 

if {($r_host equals "www.marketing-url.com")} then {
             HTTP::header replace host "not-so-friendly-domain.com"
}

But my attempts at modifying the URI or Path have not been working. Can anyone recommend a strategy for loading a website from another server & path without changing the URL? It's OK (and preferable) to display the filename after the domain, just not the original '/path-to-website/'.

 

Thanks for any help!

 

1 Reply

  • You can do a redirect:

    when HTTP_REQUEST {
    if { ([HTTP::host] eq "www.marketing-url.com") and ( [HTTP::uri] eq "/" ) } {
    HTTP::respond 301 Location "http://www.not-so-friendly-domain.com/path-to-website/"
    }
    }
    

    If you just want to replace the host and uri values and pass it to the server in pool:

    when HTTP_REQUEST {
    if { ([HTTP::host] eq "www.marketing-url.com") and ( [HTTP::uri] eq "/" ) } {
    HTTP::host "www.not-so-friendly-domain.com"
    HTTP::uri "/path-to-website/"
    }
    }