Jump to content

Recommended Posts

Hello everyone. We have just redesigned and launched a new site in php. It did run in perl and was very complicated indeed. We have built up good rankings and now want to redirect the old CGI pages with Id's to a similar page on the new php site. So basically, set up cgi-bin.guide-cgi?page=example_1 to /guide_final?page=example_1 Having real problems setting this up at the new server end. The old server has now given up the ghost but all old files and database are intact on the new server. Does anyone have a solution to this problem and any in-depth knowledge of ht access? Many thanks in advance.

 

Cooper

this should be a fairly simple rewrite rule imo

 

RewriteEngine On
RewriteRule ^cgi-bin.guide-cgi?page=(.*)$ guide_final?page=$1 [R=301,L]

 

The rule above should redirect all requests from guide_final?page=* to guide_final?page=* and with a 301 Moved Permanently header.

Thanks tomfmason - we tried something similar. It seems that when we try this the url still fails because it is looking for the cgi-bin folder and cgi.script

 

A better example I can give of what we'd want (in URL terms) is http://mydomain.com/cgi-bin/guide.cgi?paper=new_paper  to go to guide_final.php?paper= new_paper

 

Any help is VERY much appreciated!

if that wont work then you will most likely need to replace the current guide.cgi with a simple redirection script using the redirect method e.g.

 

#!/usr/bin/env perl
use CGI; 
my $q = CGI->new(); 
print $q->redirect( 
  -location => 'http://domain.tld/guide_final.php?paper=' . $q->url_param('paper'), 
  -status => 301, 
); 

 

It has been a very long time since I have written anything in perl but from what I remember that is how you would do it.

 

Thanks tomfmason - We tried these suggestions and at first it gave a server miss-configuration, but then I noticed that there was a slight typo in the word 'url' and we didn’t need the “env” in the first line.  It now works great. Thank you so much for this tomfmason, you are a star and have saved us hours of searching and head scratching. All the best, Coopertrooper.

Oooh sorry - one final thing......  The fix offered by tomfmason works on all id’s, but, is it possible to add an 'if' clause into it because if somebody comes in with “/cgi-bin/help.cgi” (no id) then it goes to our error page. Trying to work this one out??

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.