[ic] Redirecting Based on Domain

Bill Carr interchange-users@interchange.redhat.com
Wed Jan 2 15:48:49 2002


On Wed, 2002-01-02 at 11:45, Michael Stearne wrote:
> I have to do some redirecting of the user based on which URL they use to 
> some into my site with based on subdomain name.  For example:
> 
> http://am.mydomain.com/
> 
> should be replaced with
> 
> http://www.mydomain.com/fea/index.html?linecode=AM
> 
> using the subdomain name (am) capitalizing it and putting it at the end 
> of the redirect URL.  Would this be best done in Perl or in ITL using 
> the [bounce] tag in some way.
This is not to your spec but maybe it will help anyway.

In interchange.cfg:
Environment HTTP_HOST

In catalog.cfg
AutoLoad <<EOAL
[perl]
	my $host = $1 if $CGI::http_host =~ /^(\w+)\.\w+\.\w+(:\d+)?/;
	return unless $host;
	return if $host eq 'www';
	($CGI->{linecode} = $host) =~ tr/a-z/A-Z/;
	return;
[/perl]
EOAL

Note: untested.

-- 
Bill Carr
Worldwide Impact
bill@worldwideimpact.com
413-253-6700