What I'm Trying To Achieve
Given a top level URL such as http://www.myapp.com/
If somebody requests:
http://www.myapp.com/questions/id/1
I want to get the "questions/id/1" part and pass it to the appropriate Perl script to retrieve the required resource.
What I've Achieved
Currently I know how to do it if there's an extra level in the url, like so:
http://www.myapp.com/model/questions/id/1
Where "model" is simply a typical Perl CGI script except it has with no ".pl" extension and the Apache perl handler is configured to handle this and the "questions/id/1" part is interpreted as as the path info (via CGI->path_info()) passed to "model".
I go this idea from Andrew Hanenkamp's article on the subject on onlamp.com: Developing RESTful Web Services in Perl
What's Still Wrong
This approach, however, doesn't work for top level url since there's no place to put "model" or whatever the handler is called. I tried to set default documents settings in the config so that http://www.myapp.com/ to defaults to http://www.myapp.com/modle.
So that typing http://www.myapp.com/questions/id/1 is handled as http://www.myapp.com/model/questions/id/1
However, Apache thinks this is a 404 error.
How can I accomplish this? Is this even a job for Perl or better handled at the Apache config level or maybe tapping into some Apache API to catch 404 errors and extract the "/questions/id/1" part from there? I don't know. Maybe someone here knows. ;-)
Note: Apologies for the long worded and roundabout way of asking this question. I'm not quite sure what's the terminology required to elicit an on-topic answer. Mentioning a four letter word starting with R and ending with T while asking this question previously here and elsewhere has resulted heated discussions on the nature of the said for letter word and also well meaning but unhelpful suggestions to use some framework or another. I'm just curious to know how these frameworks implement this feature and I want to implement one in Perl to learn how to to do it.
Update: One of the suggested answers has led me to try mod_rewrite. Works. However, it's rather impractical to set Apache's conf manually for each mapping. Further searching has let me to the O'Reilly book, "Practical mod_perl". In it, Bekman and Cholet wrote about accessing mod_rewrite programmatically via the Apache CPAN package to set the rewrite. Appendix 10 : "mod_rewrite in Perl" Writing some code now to test this book's idea. In the mean time, if there are better ways to accomplish this, please do share.
Conclusion
After prototyping two uri routing / dispatcher (or Whatchamacallit) scripts, one relying on mod_rewrite to call it and the other on ErrorDocument; I've come to the conclusion that mod_rewrite is the correct way to implement this.
The ErrorDocument method is wrong as it does not preserve POST data from the redirected page. A no go as sending a POST request to http://www.myapp.com/questions to create a new resource is impossible as the POST data is unavailable to the custom error handler script called by ErrorDocument. Furthermore as each request by definition will not access a physical file, thus the Apache's error log will be full of spurios 404 file not found errors. This can be a huge problem is the transaction volume of the server is high. Thanks to everyone for pointing me in the right direction. Now my curiosity is satiated.