What I am Attempting To Achieve
Given a high level URL for example http://www.myapp.com/
If somebody demands:
I wish to obtain the "questions/id/1" part and pass it towards the appropriate Perl script to retrieve the needed resource.
What I have Accomplished
Presently I understand how to get it done if there's an additional level within the url, like so:
Where "model" is only a typical Perl CGI script except it's without any ".pl" extension and also the Apache perl handler is set up additional and also the "questions/id/1" part is construed as because the path info (via CGI->path_info()) passed to "model".
Time passes this concept from Andrew Hanenkamp's article about them on onlamp.com: Developing RESTful Web Services in Perl
What's Still Wrong
This method, however, does not work for the greatest url since there is no spot to put "model" or regardless of the handler is known as. I attempted to create default documents configurations within the config to ensure that http://www.myapp.com/ to defaults to http://www.myapp.com/modle.
However, Apache thinks this can be a 404 error.
How do i make this happen? Is a project for Perl or better handled in the Apache config level or possibly making use of some Apache API to trap 404 errors and extract the "/questions/id/1" part after that? I'm not sure. Maybe someone here knows. -)
Note: Apologies for that lengthy phrased and roundabout method of asking this. I am less than sure what is the terminology needed to elicit an on-subject answer. Mentioning a four letter word beginning with R and ending with T while asking this formerly here and elsewhere has resulted heated discussions around the character from the stated for letter word as well as well meaning but unhelpful tips to apply certain framework or any other. I am just curious to understand how these frameworks implement this feature and I wish to implement one out of Perl to learn to to get it done.
Update: Among the recommended solutions has brought me to test mod_rewrite. Works. However, it's rather not practical to create Apache's conf by hand for every mapping. Further searching has allow me to into the O'Reilly book, "Practical mod_perl". Inside it, Bekman and Cholet authored about being able to access mod_rewrite programmatically through the Apache CPAN package to create the rewrite. Appendix 10 : "mod_rewrite in Perl" Writing some code how to test this book's idea. In the meantime, if you will find possible ways to do this, please share.
After prototyping two uri routing / dispatcher (or Whatchamacallit) scripts, one depending on mod_rewrite to refer to it as and also the other on ErrorDocument I have arrived at the final outcome that mod_rewrite is the right way to implement this.
The ErrorDocument technique is wrong as it doesn't preserve Publish data in the rerouted page. A no go as delivering a Publish request to http://www.myapp.com/questions to produce a new resource doesn't seem possible because the Publish information is not available towards the custom error handler script known as by ErrorDocument. In addition as each request obviously won't access an actual file, thus the Apache's error log is going to be filled with spurios 404 file not found errors. This is often a huge issue is the transaction amount of the server is high. Because of everybody for pointing me within the right direction. Now my curiosity is satiated.