lukebarber has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have a simple website with some old cgi links pointing to it. I would like to redirect the old cgi links to the current .html pages. I apologize that have zero knowledge in cgi/perl programming. I was hoping that a cgi/perl programming expert can give me a tip or 2 how to redirect an old URL. The site is in a Windows 2012 server. The old URLs looks like "www.site.com/cgi-bin/site.pl?abc". Thank you very much for your help.

Replies are listed 'Best First'.
Re: Redirect a cgi URL
by Your Mother (Archbishop) on Mar 09, 2015 at 15:47 UTC

    Probably this is a job for the webserver, not the CGIs; if so, you should delete them as soon as you can. Search for .htaccess for apache or redirects for whatever other webserver you’re using. Apache example–

    # In webserver-root/.htaccess on server with cgis. redirect 301 /cgi-bin/site.pl http://site.com/new/page.html
Re: Redirect a cgi URL
by Happy-the-monk (Canon) on Mar 09, 2015 at 14:55 UTC

    There's the fine CGI redirect documentation if those cgis are using the CGI.pm module.

    Cheers, Sören

    Créateur des bugs mobiles - let loose once, run everywhere.
    (hooked on the Perl Programming language)

Re: Redirect a cgi URL
by Anonymous Monk on Mar 09, 2015 at 22:11 UTC

    Although Your Mother's suggestion to use the webserver is probably better, here's a quick replacement site.pl, I hope it's obvious how new URLs can be added:

    #!/usr/bin/perl use warnings; use strict; use CGI qw/param redirect/; my %REDIRECTS = ( 'abc' => 'http://yoursite.com/abc.html', 'def' => 'http://yoursite.com/def.html', ); my $NOT_FOUND = 'http://yoursite.com/page_not_found.html'; my $dest = param('keywords') && $REDIRECTS{param('keywords')} ? $REDIRECTS{param('keywords')} : $NOT_FOUND; print redirect(-uri=>$dest,-status=>'301 Moved Permanently');