Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Perl script to handle requests to a http://.../path/*

by xiper (Friar)
on Sep 15, 2003 at 00:33 UTC ( #291468=note: print w/replies, xml ) Need Help??


in reply to Re: Perl script to handle requests to a http://.../path/*
in thread Perl script to handle requests to a http://.../path/*

I've been playing around with mod_rewrite and it seems to be able to achieve what i'm after. That is, if i could get it working properly... :)

At the risk of being flamed for pushing this thread further off-topic, could someone help me out with this?

What i actually want to achieve is to redirect all accesses, using mod_rewrite, to a perl script, so: http://www.domain.com/foo/bar gets sent transparently to: /cgi-bin/myscript.pl?foo/bar

What i have at the moment is a .htaccess (no root, remember) that contains:

RewriteRule ^(.*)$ /cgi-bin/myscript.pl?$1 [L]
However, this gets caught in a loop, despite the [L], giving a 500 with:
mod_rewrite: maximum number of internal redirects reached. Assuming co +nfiguration error. Use 'RewriteOptions MaxRedirects' to increase the +limit if neccessary.
It was my understanding (from RTFMing!) that [L] is meant to avoid this?!? Where have i gone wrong?

Update: found a solution, chain a neg regex in front

RewriteRule !^/cgi-bin - [C] RewriteRule ^(.*)$ /cgi-bin/myscript.pl?$1 [L]

- ><iper

my JAPH: print"Just another Perl hacker\n"; # ^ look, no space! pretty tricky huh?

Replies are listed 'Best First'.
Re: Re: Re: Perl script to handle requests to a http://.../path/*
by tachyon (Chancellor) on Sep 15, 2003 at 02:50 UTC

    Just apply a RewriteCond that says NOT /cgi-bin/blah first. Then the RewriteRule will only get invoked on the first pass, not once it has been done (untested)...

    There are also other hooks to prevent looping (they let you see it this request is a subrequest of the original) but that should do the trick.

    RewriteCond ! ^/cgi-bin/myscript.pl.*$ RewriteRule ^(.*)$ /cgi-bin/myscript.pl?$1

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Thanks, although i managed to figure out a similar solution myself (although yours make more sense!).

      - ><iper

      my JAPH: print"Just another Perl hacker\n"; # ^ look, no space! pretty tricky huh?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://291468]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2023-01-30 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?