Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Need to check http referrer within home.html

Quote Reply
Need to check http referrer within home.html
Hi, I need to customise home.html to display a specific message if the user has come to my site from a specific IP address or hostname.

What's the easiest way to do this please?

Robert
Quote Reply
Re: [RobSchifreen] Need to check http referrer within home.html In reply to
Add a new global -> work_our_referer

Code:
sub {
return { refering_url => $ENV{REFERING_URI} } ;
}

...then in home.html, have;

<%work_out_referer%> (won't produce anything)

Code:
<%if refering_url eq "http://www.google.com"%>
do something here, as we would
have been refererd to by Google.com
<%endif%>

Hope that helps :) (BTW, you will need to be running in dynamic mode for this to work).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [RobSchifreen] Need to check http referrer within home.html In reply to
Another way to do it would be include the following in your .htaccess:

Code:

AddHandler server-parsed .html


and then you can include a script with

Code:
<!--#include virtual="/path/to/view.cgi"-->

which should contain something like:

Code:

#!/usr/bin/perl
use CGI;
my $in = new CGI;
my $url = $ENV{REFERING_URI};
print $in->header();
if ($url eq "whatever") {print "whatever";}
exit;

Regards

N || i k o
Quote Reply
Re: [Andy] Need to check http referrer within home.html In reply to
Thanks Andy. Because I have control over the sites that I particularly want to trap, I'll probably do it by passing a variable in the URL instead. Eg, a link from the foreign site to www.mysite.com?source=foreignsite. This will allow me to work in static mode. I did some experiments today and dynamic mode is a lot slower, and that's just in the development phase without any substantial number of users. Static mode, though, is very fast indeed.

Rob