cancel
Showing results for 
Search instead for 
Did you mean: 

URL masking

SOLVED
Highlighted
N/A

URL masking

HI I was wondering is it possible to use traffic script to mask a url for example:

 

Our website is served from : http://example.com

 

However I wish this to be presented to the client in their browser as http://newexample.com and translate any real pages via links on the site to look like they are being served by the masked domain newexample.com without effecting any functionality so the client is oblivous to the fact that they are actually using the real site which is being served from example.com.

 

Obviously we need to be incontrol of both domains  inorder for this to work but I am stuck as where to start to use traffic script to do this. This would be really great if someone could help me.

1 REPLY
Frequent Contributor

Re: URL masking

There are two ways you could approach this problem...

Redirect

The first (and easiest) is to redirect your users (issue a 302 redirect that causes their browsers to load the content from example.com when they access newexample.com.

I think that the 'http.changeSite()' trafficscript function will do what you need:


# Send users to our new site


if( http.getHostHeader() == "newexample.com" ) {


  http.changeSite( "example.com" );


}


If users request content from newexample.com, this code will redirect them to the same content on example.com using an http 302 redirect.  Note that their browser location bar will indicate that they are retrieving content from example.com, which perhaps is not what you wanted?

Rewrite

The alternative approach is to rewrite their HTTP requests and forward them to the original example.com website.  In this situation, it's sufficient to modify the host header in the request and forward it on:


if( http.getHostHeader() == "newexample.com" ) {


  http.setHeader( "Host", "example.com" );


  pool.use( "example.com servers" );


}


Then your users can browse newexample.com, and the content is retrieved from example.com.

There are a few potential pitfalls to this approach.  The content may contain links (hrefs, image srcs etc) to example.com which you would need to rewrite; the web server may issue HTTP Location redirects to example.com, or issue cookies that are tied to the example.com domain.  It's not trivial to work around these problems - the Getting Started - Load-balancing to a website using Stingray Traffic Manager article describes the steps you will need to take.