(2)No such file or directory: Can't open directory for index:
/var/www/example.com/dummy/
or some other error even though index.rhtml and index.html exist. As
far as I can tell it could be either a problem with the Apache::SiteMap
class below or the apache config. Also on that matter does anyone know
how I can get the module triggered on the host instead of the
directory?
I've attempted to look at http://modrubby.net/ but it seems to be down
so I've been using the google cache. Anyone care to give me a few
pointers, here's extracts from the relevant files,
apache config:
<IfModule mod_ruby.c>
RubyRequire sitemap
<Directory /var/www/example.com/>
SetHandler ruby-object
RubyHandler Apache::SiteMap.instance
Options +Indexes
DirectoryIndex index.rhtml index.html index.htm index.html.var
</Directory>
# other stuff
</IfModule>
sitemap.rb contains, with debugging code removed,
require "singleton"
module Apache
class SiteMap
include Singleton
@@host2dir = {'dummy.example.com' => 'dummy/'}
def handler(r)
r.content_type = 'text/html'
r.send_http_header
exit(Apache::OK) if r.header_only?
document_root = r.server.document_root
(document_root[-1] != "/") && document_root += "/"
if @@host2dir.has_key?(r.headers_in['Host'])
newdocroot = document_root + @@host2dir[r.headers_in['Host']]
filename = r.filename.sub("#{document_root}", newdocroot)
puts "sub: #{document_root} #{newdocroot} #{filename}<br>"
end
r.filename = filename
return Apache::DECLINED
end
end
end
I just woke up and my head hurts and I'm operating off the top of my head,
here, to take this for what it's worth (LOL) but I believe what you want to
do here is to use mod_ruby to write a translation handler so that your code
can give Apache a different address to use during the address translation
phase. The mod_ruby directive is
RubyTransHandler CLASSNAME
Hope that helps,
Kirk Haines
J.
Move to an earlier phase for your handler. If your handler is a
RubyInitHandler, I believe you should be able to alter the request pretty
freely as your Ruby code will gain access to it very early in the process of
handling it.
Good luck,
Kirk Haines