Forum: Ruby A ruby-web (but not rails) question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sophi I. (Guest)
on 2007-02-06 02:25
(Received via mailing list)
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!
Sam G. (Guest)
on 2007-02-06 04:43
(Received via mailing list)
On 2/6/07, itsme213 <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 they'll be served the result of your ruby script
instead.

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

http://www.thejackol.com/htaccess-cheatsheet/ should have examples.

Sam
This topic is locked and can not be replied to.