CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: mod_perl:
Seems simple enough how do I redirect old cgi scripts to mod perl?

 



ManagedLinks
New User

Sep 30, 2005, 1:35 AM

Post #1 of 4 (8230 views)
Seems simple enough how do I redirect old cgi scripts to mod perl? Can't Post

Ok here's the problem. after installing mod_perl I placed the script I wanted to run into the perl directory called it and all worked swimmingly.

The script is called by lots of clients on different web servers So I cannot easilly change the location of the script to /perl/

an easy fix or so I thought was to rewrite the url using mod rewrite so that the server would look for the script in the correct directory (/perl/) rather than the requested directory (/cgi-bin/)

I inserted this into httpd.conf in the virtual server configuration


Code
#redirect mlserver requests to the faster mod_perl 
RewriteEngine on
RewriteRule ^/cgi-bin/mlserver.pl(.*) /perl/mlserver.pl$1


Bonza it worked

but then I realised it was still running under CGI not mod_perl !

Now I cannot find a way to get the script running under mod_perl. CGI always takes over!
if I remove the shebang line the script fails
if I call it directly ie: server.com/perl/mlserver.pl it works correctly under mod_perl

How can I redirect an incoming request to the new mod_perl script?

I know this question is probably more an apache one, but I hope someone here can assist

I have tried renaming the script to mlserver.perl and the setting a new handler
ie: AddHandler perl-script .perl
but all that does is send back plain text, it doesn't execute mod_perl at all

Any ideas apart from telling all my clients to change the code on hundreds of sites?


rork
User

Sep 30, 2005, 1:51 AM

Post #2 of 4 (8228 views)
Re: [ManagedLinks] Seems simple enough how do I redirect old cgi scripts to mod perl? [In reply to] Can't Post

Maybe not the best solution, but can't you redirect to the new script from the old script?
--
Don't reinvent the wheel, use it, abuse it or hack it.


ManagedLinks
New User

Sep 30, 2005, 5:09 PM

Post #3 of 4 (8219 views)
Re: [rork] Seems simple enough how do I redirect old cgi scripts to mod perl? [In reply to] Can't Post

unfortunately this script is called thousands of times an hour, which is why its going to mod_perl

using a standard redirection doubles the network activity and increases the time the client is waiting for a response. because of the nature of the script it is set to time out after 5 seconds

so redirections are not an option. but thanks for the input

obviously apache processes handlers before rewrites and not after.

I cant find a way for the process to be "rehandled"

Ta for the input


ManagedLinks
New User

Sep 30, 2005, 5:11 PM

Post #4 of 4 (8218 views)
Re: [ManagedLinks] Seems simple enough how do I redirect old cgi scripts to mod perl? [In reply to] Can't Post

Found the Answer WooHoo

instead of the rewrite I can just tell Apache to handle the script itself as a mod_perl script using


Code
<Location /cgi-bin/mlserver.pl> 
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
allow from all
PerlSendHeader On
</Location>


that solves the problem and avoids a rewrite in the bargain

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives