coopertrooper Posted December 6, 2011 Share Posted December 6, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/252585-problem-redirecting-cgi-id-pages-to-new-php-pages/ Share on other sites More sharing options...
tomfmason Posted December 7, 2011 Share Posted December 7, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/252585-problem-redirecting-cgi-id-pages-to-new-php-pages/#findComment-1295186 Share on other sites More sharing options...
coopertrooper Posted December 7, 2011 Author Share Posted December 7, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/252585-problem-redirecting-cgi-id-pages-to-new-php-pages/#findComment-1295215 Share on other sites More sharing options...
tomfmason Posted December 7, 2011 Share Posted December 7, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/252585-problem-redirecting-cgi-id-pages-to-new-php-pages/#findComment-1295253 Share on other sites More sharing options...
coopertrooper Posted December 8, 2011 Author Share Posted December 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/252585-problem-redirecting-cgi-id-pages-to-new-php-pages/#findComment-1295686 Share on other sites More sharing options...
coopertrooper Posted December 8, 2011 Author Share Posted December 8, 2011 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?? Quote Link to comment https://forums.phpfreaks.com/topic/252585-problem-redirecting-cgi-id-pages-to-new-php-pages/#findComment-1295703 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.