Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I have a file "makecategory.pl".
I pass 2 query string to it viz categoryid and siteid.
Now when this file comes up in the browser as "http://localhost/makecategory.pl?categoryid=17&siteid=1" , I want to display it in the browser as "http://localhost/makecategory/17/1" i.e in the address bar .
I have heard that mod rewrite helps in doing that.
I tried a lot of rewrite rules however i am unable to resolve my problem .
Can someone let me know how I can achieve the above using mod rewrite .
Thankyou !

Replies are listed 'Best First'.
Re: perl file + .htaccess + mod rewrite
by sgifford (Prior) on Apr 27, 2004 at 15:32 UTC
    If you're using the CGI module, I think you're looking for the path_info function:
           path_info()
               Returns additional path information from the script
               URL.  E.G. fetching /cgi-bin/your_script/addi­
               tional/stuff will result in $query->path_info()
               returning "/additional/stuff".
    
    
Re: perl file + .htaccess + mod rewrite
by b10m (Vicar) on Apr 27, 2004 at 16:19 UTC

    Apache's RewriteRules can indeed solve your problem. Would you care to post what you have tried so far and the results you got? Then we might be able to tweak your rules :)

    --
    b10m

    All code is usually tested, but rarely trusted.
      RewriteRule makecategory/(.*)/(.*) makecategory.pl?categoryid=$1&sitei +d=$2
      should work
Re: perl file + .htaccess + mod rewrite
by BUU (Prior) on Apr 27, 2004 at 21:14 UTC
    It looks like you are going at it from the wrong direction. You want the browser to pass you a url like "http://localhost/makecategory/17/1" and then mod_rewrite will munge it so it looks like a proper CGI query string and pass it to your cgi script.