Identify the referrer domain in r ails

Hi All,

I have a web site which has 2 domains

ex : www.site1.com       www.site2.com (which will forward to www.site1.com with domain masking)

www.site1.com is where the actual web server rungs

www.site2.com is just a domain name forwarder and I use mask to make the user feel he/she is in www.site2.com even though he/she is in www.site1.com

But in underlying code I want to distinguish both the request (who came from www.site1.com and who came from www.site2.com) so that I can load their UI accrodingly

I tried request.host as well as request.referrer which always gives www.site1.com

and when I get the source code of the www.site2.com (which redirects to site1) it has this,

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"    "http://www.w3.org/TR/html4/strict.dtd&quot;&gt; <html>

<head>   <title>sameera gayan </title>   <META name="description" content="test"><META name="keywords" content="test"> </head> <frameset rows="100%,*" border="0">   <frame src="http://www.site1.com" frameborder="0" />   <frame frameborder="0" noresize /> </frameset>

<!-- pageok --> <!-- 04 --> <!-- --> </html>

So what is the best option for getting the 2 different site URL's ,

thanks in advance

cheers, Sameera

Sameera,

You will need to write some JS (document.referrer) to include the referrer in the URL when you do the redirect to the second site. Then on the second site, you will need to extract the URL from the query string. Make sense?

Darian Shimy

This is not the best in doing such things. In this case, it’s logical that you never see ‘site2.com’ in your request.host attribute.

First of all, in your DNS both ‘site1.com’ & ‘site2.com’ should point the same ip address.

Then on your server, you should configure your webserver that both ‘site1.com’ & ‘site2.com’ urls point to the same directory and then you can access the request.host which the right hostname set.

Cya C+++