# A ruby-web (but not rails) question

**URL:** <https://www.ruby-forum.com/t/a-ruby-web-but-not-rails-question/84569>\
**Category:** Ruby\
**Created:** [February 6, 2007, 1:25am UTC](https://www.ruby-forum.com/t/a-ruby-web-but-not-rails-question/84569 "2007-02-06T01:25:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsme213](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/258eb7/32.png) [@itsme213](https://www.ruby-forum.com/u/itsme213)\
**Post date:** [February 6, 2007, 1:25am UTC](https://www.ruby-forum.com/t/a-ruby-web-but-not-rails-question/84569/1 "2007-02-06T01:25:39Z")

</div>

I am trying to do something very simple. My web dir structure:

home/  
index.html  
cgi-bin/  
login (a ruby script)

I have a form/button in index.html, and when submitted the action is to  
run  
cgi-bin/login. I have the necessary #! header etc.

I want the login script to return the same index.html file (except for  
one  
minor substitution), but it should appear to the client browser to come  
from  
home/ so that relative links will continue to work, rather than from  
cgi-bin. The following almost works, except it is based out of cgi-bin.

#!/usr/local/bin/ruby  
print “Content-type: text/html\n\n”  
home\_page = IO.read “…/index.html”  
print home\_page

Any simple solution?

Thanks!

---

<div class="post-metadata">

**Author:** ![itsme213](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/258eb7/32.png) [@itsme213](https://www.ruby-forum.com/u/itsme213)\
**Post date:** [February 6, 2007, 3:43am UTC](https://www.ruby-forum.com/t/a-ruby-web-but-not-rails-question/84569/2 "2007-02-06T03:43:50Z")

</div>

On 2/6/07, itsme213 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want the login script to return the same index.html file (except for one  
> minor substitution), but it should appear to the client browser to come from  
> home/ so that relative links will continue to work, rather than from  
> cgi-bin.

This sounds like a job for .htaccess.

You can set your DirectoryIndex to point to index.rb (or login, or  
whatever) instead of index.html, so when people go to  
[http://yoursite/home](http://yoursite/home) they’ll be served the result of your ruby script  
instead.

You may also need to enable CGI in your home directory (using  
AddHandler).

[the jackol’s den - Mikhail Esteves](http://www.thejackol.com/htaccess-cheatsheet/) should have examples.

Sam
