I've written a new mod_perl-driven application which takes a URI (with the scheme of news://, http://, and ftp:// so far), a limit, and some other params, and passes them into my script.

CGI.pm splits off param(), validates the input, and passes the params off to the proper subs, based on the values of the data found. So far, so good...

What I'm trying to figure out, is a way to take the following style URI fragment, which includes the "raw" params and query string:

http://www.example.com/?type=news&feed=news://comp.lang.c&limit=10

...and turn it into something "nicer" for the user to remember and use in the future, like this:

http://www.example.com/news/comp.lang.c/10

I'm not the best with mod_rewrite, and I think it can help here, but I'm not sure how to "split" the fragments passed in on '/', and pass those to CGI.pm to parameterize.

Would something like this help?

RewriteRule ^/(.*)/(.*)/(.*)   /index.pl?type=$1&feed=$2&limit=$3

Or perhaps there's a better approach? Ideas and suggestions are welcome.


In reply to mod_rewrite + CGI.pm in "reverse"? by hacker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.