# Mapping file-not-found to a .rb file?

**URL:** <https://www.ruby-forum.com/t/mapping-file-not-found-to-a-rb-file/146009>\
**Category:** Ruby\
**Created:** [August 16, 2008, 1:50am UTC](https://www.ruby-forum.com/t/mapping-file-not-found-to-a-rb-file/146009 "2008-08-16T01:50:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [August 16, 2008, 1:50am UTC](https://www.ruby-forum.com/t/mapping-file-not-found-to-a-rb-file/146009/1 "2008-08-16T01:50:20Z")

</div>

I am using latest Apache on Linux. I would like to have something like  
this:

localhost/query  
localhost/query/foobar

All these should be mapped to a specific .rb file but I wonder which  
limitation this would have (I’d want to have as few restrictions as  
possible), and how to make this even possible at all. Would this require  
mod\_rewrite or are there simpler alternatives? Preferrable I would not  
want to run a daemon .rb file.

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [August 19, 2008, 3:13am UTC](https://www.ruby-forum.com/t/mapping-file-not-found-to-a-rb-file/146009/2 "2008-08-19T03:13:01Z")

</div>

Marc H. wrote:

> Would this require  
> mod\_rewrite or are there simpler alternatives? Preferrable I would not  
> want to run a daemon .rb file.

You could just make a Ruby cgi script. Then, yes, some mod\_rewrite  
trickery should get you the desired results.

However, you might want to reconsider running a daemon .rb file. The  
main reason that Rails/Rack/etc. go this route is that starting a Ruby  
process is often the most intensive part of running a Ruby script  
(doubly-so in the case of JRuby). Having a Ruby process idling and  
waiting for requests is often more efficient.
