Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Perl file names and extensions

by nite_man (Deacon)
on Aug 03, 2004 at 15:51 UTC ( #379712=note: print w/replies, xml ) Need Help??


in reply to Perl file names and extensions

Let's see how do it with mod_perl (example from mod_perl documentation):
This is an URL on website -

http://example.com/news/20021031/09/index.html
but you need convert it as
http://example.com/perl/news.pl?date=20021031&id=09&page=index.html
You can use for that simple mod_perl handler:
package MyApache::RewriteURI; use strict; use warnings; use Apache::RequestRec (); use Apache::Const -compile => qw(DECLINED); sub handler { my $r = shift; my($date, $id, $page) = $r->uri =~ m|^/news/(\d+)/(\d+)/(.*)|; $r->uri("/perl/news.pl"); $r->args("date=$date&id=$id&page=$page"); return Apache::DECLINED; } 1;
Also, you should add in http.conf:
PerlTransHandler +MyApache::RewriteURI
So, first URL is easier to understand for user than second. Also, based on this you can create something like selector to process and redirect HTTP requests according your rules.

---
Schiller

It's only my opinion and it doesn't have pretensions of absoluteness!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2021-06-22 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (104 votes). Check out past polls.

    Notices?