#!/usr/bin/perl @excludeurls=( '.*.oqo.com', '.*.oqo.net', 'oqo.com', 'oqo.net', '127.0.0.1' ); $ref=$ENV{'HTTP_REFERER'}; $query=$ENV{'QUERY_STRING'}; $addquery= "&$query" if $query; $onlyquery= "?$query" if $query; $ref=~s/.*:\/\///g; $ref=~s/\/.*$//g; foreach $test (@excludeurls) { if ($ref=~/$test/i) { $ref=''; last; } } #look for cookie that's set by a referrer. #overrides referral URL @cookies = split(/\; /,$ENV{'HTTP_COOKIE'}); foreach $cookie (@cookies) { local($cname,$cval)=split(/=/,$cookie); $cookie{$cname}=$cval; } if ($cookie{'referral'}) { $ref=$cookie{'referral'}; } if ($ref) { $location="/store/shop.cgi/op/op_index.html?source=$ref$addquery"; } else { $location="/store/shop.cgi/op/op_index.html$onlyquery"; } #add leading / if missing $location="/$location" unless ($location=~/^\//) || ($location=~/^http:/); #add the server name if needed. $location=" http://" . $ENV{'SERVER_NAME'} . "$location" unless $location=~/^http:/; print "Location: $location\n\n";