A script to redirect based on the subdomain (like: [login to view URL] vs. [login to view URL])

Cancelado Publicado Oct 29, 2012 Pagado a la entrega
Cancelado Pagado a la entrega

I found a perl script years ago that I installed on my shared hosting webserver as [url removed, login to view] and did what I needed: if you type [url removed, login to view] in your web browser, the page would redirect to 1 page, vs. [url removed, login to view] would go to another page. I had dozens of these redirects I used as shortcuts to different apps, utilities, etc.

For some reason with my hostgator account, it stopped working. I need you to either get this working or give me another script that does the same thing that I can add as many redirects as I want.

## Deliverables

Here's the basics of the script. This assumes my domain is [url removed, login to view], which it is not:

(I added the line numbers manually in the question. They are NOT in the script:

1) #!/usr/local/bin/perl

2) $mainpage = "[url removed, login to view]";

3) %domains = (

4) '[url removed, login to view]' => '[url removed, login to view]',

5) '[url removed, login to view]' => '[url removed, login to view]',

6) '[url removed, login to view]' => '[url removed, login to view]'

7) );

8) $server = lc($ENV{'HTTP_HOST'});if ($ENV{'HTTP_HOST'} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+<wbr />)/){$t='/'<wbr />}else{if ($server !~ /^www./){$server = '' . $server;}}@domains = keys(%domains);foreach $domain(@domains){if ($domain eq $server){print "Location: $domains{$server}\n\n";$ma<wbr />tch="yes";<wbr />last;exit}<wbr />}unless($m<wbr />atch){prin<wbr />t "Location: [url removed, login to view]\n\n";exit<wbr />}exit;

Normally, there would be loads of those line 4 and 5. The last of them - line 6 in this case - needs to NOT have the comma at the end. I AM NOT a developer / coder : ) I just figured these things out over time.

Hostgator had me install an SSH client and this is the error I get when I run it:

and the errors I get even with this very short list of redirects:

a@[url removed, login to view] [~/public_html]# perl -w [url removed, login to view]

Name "main::t" used only once: possible typo at [url removed, login to view] line 8.

Name "main::mainpage" used only once: possible typo at [url removed, login to view] line 2.

Use of uninitialized value in pattern match (m//) at [url removed, login to view] line 8.

Location: [url removed, login to view]

I don't know if these are non-critical errors? I never did this when it was working OK

Amazon Web Services PHP Arquitectura de software Verificación de software Web Hosting Gestión de páginas web Verificación de páginas web

Nº del proyecto: #2788577

Sobre el proyecto

6 propuestas Proyecto remoto Activo Nov 3, 2012

6 freelancers están ofertando un promedio de $30 por este trabajo

bgeorge

See private message.

$34 USD en 14 días
(239 comentarios)
6.3
gigabitware

See private message.

$34 USD en 14 días
(49 comentarios)
5.7
f1x3r

See private message.

$30.6 USD en 14 días
(9 comentarios)
4.0
jonathanhooton

See private message.

$25.5 USD en 14 días
(18 comentarios)
3.5
itsazzad

See private message.

$30.6 USD en 14 días
(2 comentarios)
2.0
mfelch

See private message.

$25.5 USD en 14 días
(1 comentario)
0.0