PDA

View Full Version : NEED cgi-script for having subdomains and even 2 domains on one IP !



akersche
July 13th, 2001, 09:49
Hello,

I know there have been already some threads about this topic. And I know I could just use forwarding with e.g. mydomain.com.

BUT then useres don't see the file and path of the actual file. (Know about path forwarding... But that's not what I am looking for.)

I already found some scripts, but not sure, which could do that. And if it's possible on my host.
(Didn't manage to get it working yet:-( )

It should be, cause I got a unique IP and server seems to allow wildcards. (virtual site on tera-byte)

I really need urgent subdomains... Cause I have given them out before (used to have mydomain with just url-forwarding).

What script would do that?!
For the moment forwarding would be also ok...

Thx for your help in advance!

Greetings Arno

PS: Tried following:

DomainDirector v1.1
http://www.scriptsolutions.com/


And set it like this:
#!/usr/bin/perl --

############################################################ ####
# #
# DomainDirector v1.1 #
# Copyright ©1999 - Tintagel Consulting, LLC #
# dba Script Solutions #
# http://www.scriptsolutions.com/ #
# All rights reserved #
# #
############################################################ ####
# #
# PURPOSE OF PROGRAM: #
# #
# DomainDirector v1.1 allows you to direct parked domains to a #
# subdirectory of a "primary" domain. #
# #
# #
# INSTRUCTIONS: #
# #
# Installation instructions are in the readme.txt file that #
# was included in this distribution. #
# #
# #
# LICENSE AGREEMENT: #
# #
# By installing DomainDirector v1.1, you have #
# agreed to indemnify, defend, and hold harmless Tintagel #
# Consulting, LLC dba Script Solutions from any and all #
# liability, penalties, losses, damages, costs, expenses, #
# attorneys' fees, causes of action or claims caused by or #
# resulting indirectly from your use of this script which #
# damages either you, or any other party or parties without #
# limitation or exception. This indemnification and hold #
# harmless agreement extends to all issues associated with #
# this script. #
# #
############################################################ ####


############################################################ ####
# #
# EDIT BELOW #
# #
############################################################ ####

$mainpage = "home.htm";


%domains = (
'www.board.kersche.net' => 'board.htm',
'www.job.kersche.net' => 'job.htm',
'www.party.kersche.net' => 'party.htm',
'www.schloegi.party.kersche.net' => 'schloegi.htm',
'www.outdooracademyaustria.com' => 'main.html'
);





############################################################ ####
# DO NOT CHANGE BELOW THIS LINE! #
############################################################ ####

$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/$mainpage\n\n";exit}exit;

akersche
July 13th, 2001, 13:04
just hear (from the paid host forum), that it should work on tera-byte.

anyone sees, what i did wrong, or knows a diffrent script, that works?

gyrbo
July 13th, 2001, 14:14
Originally posted by akersche
#!/usr/bin/perl --

Is this just a typo, or should this be?

akersche
July 13th, 2001, 14:22
i tried it first without --
but i saw on tera-byte, that it's a good idea to use that. shouldn't change anything about the script. and i don't get an error... but i am just not redirected as i want to...
(always get to my main page:-( )

at the moment i am testing another script:
and use index.shtml to run the script:
<html>
<body>
<!--#exec cgi="index.cgi" -->
</body>
</html>



!/usr/bin/perl
############################################################ ###################
# Virtual Redirect version 1.0
# Created by Blacksheep, Inc.
# http://www.blacksheep3d.com/
#
# For a current version of this script, please visit
# http://www.blacksheep3d.com/freescripts/
#
# Feel free to modify all you like. You are not required to, but it would be
# nice if you put a link somewhere on your site to
# http://www.blacksheep3d.com/freescripts/
#
# If you do make changes and decide to distribute, please give us partial
# credit for the code you based your new creation on.
#
# Alter %Domain_Names to suit your needs. Insert the domain name or sub domain
# name to look for in the left column. Insert the URL to redirect users to
# that go to the domain name or sub domain name in the right column next to
# the original domain name the user went too.
#
# Alter $Default_URL to point towards the URL that is the catch all.
#
# Rename this script index.cgi and place in your domain's directory.
# chmod 766
#
# BE CAREFUL WITH WHERE YOU REDIRECT PEOPLE TOO. MAKE SURE THAT YOU DO NOT
# PUT A REDIRECT URL TO A URL THAT WILL CALL THIS SCRIPT AGAIN. DOING SO WILL
# CAUSE AN ENDLESS LOOP AND WILL UPSET YOUR USERS AND YOUR ISP.
#
############################################################ ##################
#
# Domain Name Redirect To URL
#

%Domain_Names = (
"board.kersche.net" => "http://www.kersche.net/~board/",
"outdoor.kersche.net" => "http://www.kersche.net/~outdoor/",
"www.kersche.net" => "http://www.kersche.net/job.htm");

$Default_URL = "http://www.kersche.net/job.htm";

############################################################ ###################
# Nothing below this needs to be altered to use the script
############################################################ ###################


foreach $line (keys(%Domain_Names)) {
if ($ENV{'HTTP_HOST'} =~ /$line/i) {
print "Location: $Domain_Names{$line}\n\n";
exit;
}
}

print "Location: $Default_URL\n\n";

gyrbo
July 13th, 2001, 14:34
Wow, these scripts just check the URL that is passed to them, it should be fairly easy to make one of your own.

akersche
July 13th, 2001, 14:39
i know, it shouldn't be that tricky to code it on my own...
BUT why would i do that, when there are already scripts availiable...
the 2nd i posted is not that good... just would show a page with a link to the correct page...
but i could have it temporary until i manage to get a better one working....

still it's also not working correct:-(

when i type:
http://www.kersche.net
i get redirected to the same url as
when i type:
http://board.kersche.net