Hoi,
Ik ben nogal een beginner op het vlak van perl programmeren,
maar ik zit met het volgende probleem;
ik heb namelijk 1 ip adres waar ik 2 domeinen wil op hosten..
addon-domains is disabled .. dus kan ik het niet oplossen via virtual domains ~apache
Na wat gezocht te hebben op het web, heb ik volgend scriptje gevonden:
-----------------------------------------------------------------------------
I've solved this one with SSI and Perl. I'm using SSI to hide the fact that
the user is redirected based on the domain name.
The index.shtml file in my HTML root contains only one line:
<!--#exec cgi="/cgi-bin/domain.pl" -->
Then, in my cgi-bin, I've created a Perl script named domain.pl and a data
file (plain text) named domain.data. The domain.data file contains domain
names matching the relative URL; sample line:
download.kaa.no::/download/
The domain.pl file is like this:
I changed the path so it's easier to understand (and for security reasons).
Using the sample line above, http://download.kaa.no/ will show the website
located at http://download.kaa.no/download/ which is also located at
http://kaa.no/download/ because it's all hosted on one single account and
same IP.
-----------------------------------------------------------------------------
ik heb het path aangepast en de juiste gegevens geplaatst in domain.data..
maar toch krijg ik enkel een lege html pagina..
Moet ik nog iets chmodden ofzo, iets enablen, is die "Location: " mis?
iemand raad?
tx in advance
jr3
Ik ben nogal een beginner op het vlak van perl programmeren,
maar ik zit met het volgende probleem;
ik heb namelijk 1 ip adres waar ik 2 domeinen wil op hosten..
addon-domains is disabled .. dus kan ik het niet oplossen via virtual domains ~apache
Na wat gezocht te hebben op het web, heb ik volgend scriptje gevonden:
-----------------------------------------------------------------------------
I've solved this one with SSI and Perl. I'm using SSI to hide the fact that
the user is redirected based on the domain name.
The index.shtml file in my HTML root contains only one line:
<!--#exec cgi="/cgi-bin/domain.pl" -->
Then, in my cgi-bin, I've created a Perl script named domain.pl and a data
file (plain text) named domain.data. The domain.data file contains domain
names matching the relative URL; sample line:
download.kaa.no::/download/
The domain.pl file is like this:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
| #!/usr/bin/perl
open(DOMAIN,"/usr/home/path.to.html.root/cgi-bin/domain.data");
@domains = <DOMAIN>;
close(DOMAIN);
$nowdom = $ENV{'HTTP_HOST'};
$tourl = "/home.shtml";
foreach $dompair (@domains) {
($domain, $url) = split(/::/, $dompair);
if (index($nowdom,$domain) != -1) {
$tourl = $url;
}
}
print "Location: $tourl\n\n"; |
I changed the path so it's easier to understand (and for security reasons).
Using the sample line above, http://download.kaa.no/ will show the website
located at http://download.kaa.no/download/ which is also located at
http://kaa.no/download/ because it's all hosted on one single account and
same IP.
-----------------------------------------------------------------------------
ik heb het path aangepast en de juiste gegevens geplaatst in domain.data..
maar toch krijg ik enkel een lege html pagina..
Moet ik nog iets chmodden ofzo, iets enablen, is die "Location: " mis?
iemand raad?
tx in advance
jr3