in reply to Telling different virtual hosts apart
So I'm developing a backend CGI script that several virtual hosts will need to hit.it seems that your script is NOT running on a virtual host but is being accessed (via HTTP) by other virtual hosts, and the behavior of your script is dependent on what virtual host is making the call. Is that correct?
Secondly, when you write:
I guess I could go by the referer for the CGI objectdo you mean $ENV{HTTP_REFERER} or $ENV{REMOTE_HOST}?
In any case, my approach would be to develop a small rule engine that would allow your customize it for subdomains if you ever needed to:
my %domain_map; $domain_map{'yahoo.com'} = ...default setting for all of yahoo.com... $domain_map{'special.yahoo.com'} = ...special setting for special.yaho +o.com... sub find_setting { my $domain = shift; # either from $ENV{HTTP_REFERER} or $ENV{REMOTE +_HOST} my $setting; while (length($domain)) { defined($setting = $domain_map{$domain}) && last; $domain =~ s/^(.*?)(\.|\z)//; } return $setting; }
|
|---|