Toon posts:

[PERL] redirect scriptje

Pagina: 1
Acties:
  • 35 views sinds 30-01-2008

Verwijderd

Topicstarter
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:

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

  • whoami
  • Registratie: December 2000
  • Laatst online: 10:17
Hoi.

P&W is een forum waar er van jezelf ook enige inzet verwacht wordt. Aangezien je aangeeft dat je zelf nog maar een beginner bent op het gebied van Perl, is het misschien een idee om eens zelf eea bij te leren over Perl.
Verder levert P&W ook geen ondersteuning voor scripts die door derden gemaakt zijn. Misschien kan je best eens de maker van het script contacteren ivm jouw probleem. Hij zal wel beter in staat zijn om jou te helpen met zijn script .

Succes.

https://fgheysels.github.io/


Dit topic is gesloten.