Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Perl file names and extensions

by nite_man (Deacon)
on Aug 03, 2004 at 15:51 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://379712]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-24 01:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found