gthorley
02-17-2001, 04:22 PM
A while ago the following script placed in index.cgi was posted in a thread which directed domain names into specific folders. It required that an .htaccess file be set up pointing to index.cgi as the default opening file.
#!/usr/bin/perl
$home = "index.html";
%domains = (
'www.domain1.com' => 'domain1/',
'www.domain2.com' => 'domain2/',
'www.domain3.com' => 'domain3/',
);
$server = lc($ENV{'HTTP_HOST'});if ($ENV{'HTTP_HOST'} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/){$t='/'}else{if
($server !~ /^www./){$server = 'www.' . $server;}}@domains = keys(%domains);foreach
$domain(@domains){if ($domain eq $server){print "Location:
http://${server}/$domains{$server}\n\n";$match="yes";last;exit}}unless ($match){print "Location:
http://$server/$home\n\n"; exit}
exit;
I have tried to set this up but cannot get it to work. In my case I only have a http://www.domain1.com set up and this is directed to the main site by IP pointing from mydomain.com.
Both .htaccess and index.cgi are working but the second domain pointed to my IP keeps loading in whatever index file I set up for the primary domain.
Anyone have any ideas as to what can be done. My suspicion is that the script reads the domain directed by mydomain.com as my hosted domain and then directs it based on that info. The interesting thing is that location box shows the directed domain as follows http://www.domain1.com/index.shtml
#!/usr/bin/perl
$home = "index.html";
%domains = (
'www.domain1.com' => 'domain1/',
'www.domain2.com' => 'domain2/',
'www.domain3.com' => 'domain3/',
);
$server = lc($ENV{'HTTP_HOST'});if ($ENV{'HTTP_HOST'} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/){$t='/'}else{if
($server !~ /^www./){$server = 'www.' . $server;}}@domains = keys(%domains);foreach
$domain(@domains){if ($domain eq $server){print "Location:
http://${server}/$domains{$server}\n\n";$match="yes";last;exit}}unless ($match){print "Location:
http://$server/$home\n\n"; exit}
exit;
I have tried to set this up but cannot get it to work. In my case I only have a http://www.domain1.com set up and this is directed to the main site by IP pointing from mydomain.com.
Both .htaccess and index.cgi are working but the second domain pointed to my IP keeps loading in whatever index file I set up for the primary domain.
Anyone have any ideas as to what can be done. My suspicion is that the script reads the domain directed by mydomain.com as my hosted domain and then directs it based on that info. The interesting thing is that location box shows the directed domain as follows http://www.domain1.com/index.shtml
