jtc970 -
Joined: 24 Mar 2003 Posts: 172
|
Posted: Sat Jan 10, 2004 10:39 am Post subject: |
|
|
if you have perl running you can use this script
just have abyss point to this first as the index.pl
Code: | #!/usr/bin/perl -w
use strict;
#use CGI::Carp qw/ fatalsToBrowser /;
################################################################
# #
# DomainDirector v2.2 #
# http://www.scriptsolutions.com/ #
# All rights reserved #
# #
# Domain Director is copyright 1998-2003, Creative #
# Fundamentals, Inc. It is distributed under the same #
# terms as Perl itself. See the "Artistic License" at #
# http://www.opensource.org/licenses/artistic-license.html for #
# licensing terms. #
# #
################################################################
################################################################
# Enter the main page of your primary website
my $mainpage = 'index.html';
################################################################
# If your server has wildcards enabled, then enter 1 below.
# Otherwise, enter 0 (that's a zero, not a capital o)
my $wildcards = 0;
################################################################
# To make redirection more transaparent, you can choose to use
# lwp, which will fetch the page and display it without
# causing a change in the browser address bar. If you have lwp
# installed on your server and want to use transparent
# redirection, enter 1 if you don't, enter 0
# When using lwp, be sure that your target pages use absolute
# urls for your images and links. eg:
# <IMG SRC="http://www.domain.com/images/image.gif"> instead of
# <IMG SRC="image.gif">
my $use_lwp = 0;
################################################################
# Enter domain names below that you do not want to be
# redirected via wildcards. By default, wildcarded domains
# will use http://wildcarddomain.domain.com/wildcarddomain/, so
# if something needs to be redirected differently, define the
# domain and the page it needs to be redirected to here.
# Note that if you have 4th level domains
#(eg my.fourth.level.domain.com) or higher, each level will be
# its own subdirectory in reverse. eg:
# http://my.fourth.level.domain.com/level/fourth/my/
# To redirect to an off-server web page, use the fully qualified url,
# such as http://offsite.com/page.html
# To redirect to a page on the server this program is installed, simply
# enter the path to the file starting from the domain name.
my %domains = (
'www.spartanpacific.com' => '/spartan/index.htm',
'www.yourname.com' => 'http://wherever.com',
);
################################################################
# DO NOT CHANGE BELOW THIS LINE! #
################################################################
my ( $match, $server ) = ( 0, undef );
( $server = lc( $ENV{'HTTP_HOST'} ) ) =~ s/^www\.//;
$server = "www.$server" if ($server =~ tr/\.// == 1);
for my $domain( keys %domains ){
if ( lc $domain eq $server ){
$match = 1;
if ($domains{$server} =~ m|http://|){
fetch_page( $domains{$server} );
}
else {
fetch_page( "http://$server/$domains{$server}" );
}
}
}
unless ( $match == 1 ){
my $url = "http://$server/$mainpage";
if ( $wildcards && $server !~ /^www\./ && $server !~ /^(\d{1,3}\.){3}\d{1,3}$/ ){
my @domain = split( /\./, $server );
splice ( @domain, -2 ); # throw away first and second levels of domain
my $dir = join( '/', reverse @domain ) ;
$url = "http://$server/$dir/";
}
fetch_page( $url );
}
sub fetch_page {
my $url = shift;
eval { require LWP::UserAgent };
if ( $@ || !$use_lwp ){
print "Location: $url\n\n";
return;
}
else {
my $webagent = new LWP::UserAgent;
my $response = $webagent->request( new HTTP::Request( GET => $url ) );
if ( $response->is_success ) {
print "Content-type: text/html\n\n", $response->content, "\n";
return;
}
}
print "Location: $url \n\n";
return;
}
|
|
|